RewriteCond simply doesn't work, doesn't check properly if file exists

Posted by ultranol on Stack Overflow See other posts from Stack Overflow or by ultranol
Published on 2010-05-12T18:19:32Z Indexed on 2010/05/12 18:24 UTC
Read the original article Hit count: 164

Hey everybody.

I've been trying to solve this for hours now but came up with nothing.

Inside .htaccess, whenever somebody requests an image from a folder of my website, I'm trying to check if a file with the same name exists in another folder; if it does, return that file; if it doesn't, return the file originally requested.

It seems so easy but it simply doesn't work. The .htaccess code is as follows:

RewriteEngine On

RewriteCond /images/blog/watermark/$1 -f
RewriteRule ^(.*) /images/blog/watermark/$1

The "RewriteCond" always returns negative, so the image requested is always loaded as is. If I change it to, like,

RewriteCond %{REQUEST_FILENAME} -f

it always returns positive, so it gets the image from the folder I want - except when the image's not there, generating an error, which is exactly what I'm trying to prevent.

What am I doing wrong?

Thanks.

© Stack Overflow or respective owner

Related posts about .htaccess

Related posts about apache