Thank you Jens-U. for your help.

I enabled log for URL rewriting, here is what I get if I request /icon.png
(DocumentRoot = /home/yvand/www)

127.0.0.1 - - [09/Jul/2013:14:41:28 +0200] [localhost/sid#f884e0][rid#11f2bc0/initial] (3) [perdir /home/yvand/www/] strip per-dir prefix: /home/yvand/www/icon.png -> icon.png 127.0.0.1 - - [09/Jul/2013:14:41:28 +0200] [localhost/sid#f884e0][rid#11f2bc0/initial] (3) [perdir /home/yvand/www/] applying pattern '^(.+)' to uri 'icon.png' 127.0.0.1 - - [09/Jul/2013:14:41:28 +0200] [localhost/sid#f884e0][rid#11f2bc0/initial] (1) [perdir /home/yvand/www/] pass through /home/yvand/www/icon.png
yvand:~/www$

It seems REQUEST_FILENAME refers to icon.png as expected.
But I don't understand why it doesn't add pictures in the URL

--yvand

Le 09/07/2013 15:39, Jens-U. Mozdzen a écrit :
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



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

Reply via email to