Hi yvand,

Zitat von yvand <yvand.sw...@gmail.com>:
Hi all,

I want to redirect all requests like /icon.png to /pictures/icon.png, if the file exists in the pictures folder.
It seems really trivial but I didn't manage to set up.

Here is my .htaccess :
    RewriteEngine On
    RewriteCond /pictures/%{REQUEST_FILENAME} -f
    RewriteRule ^(.+) /pictures/$1 [L]

If I request /pictures/icon.png it works, but if I request /icon.png I get a 404 error.

What is wrong with my .htaccess?

as you are in .htaccess (and not in global server/vhost context), I'd expect REQUEST_FILENAME to be the full path of the resource. From http://httpd.apache.org/docs/2.4/mod/mod_rewrite.html#rewritecond :

"The full local filesystem path to the file or script matching the request, if this has already been determined by the server at the time REQUEST_FILENAME is referenced."

You may want to set up mod_rewrite logging (http://httpd.apache.org/docs/2.4/mod/mod_rewrite.html#logging) to verify this... the logging is generally *very* helpful in debugging such problems.

Regards,
Jens


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org

Reply via email to