httpd-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrea Rossignoli <>
Subject REQUEST_FILENAME usage in mod_rewrite 1.3 doc
Date Fri, 12 Sep 2003 07:26:10 GMT
in my opinion some examples from are not correct.

In particular I'm talking about of some usages of %{REQUEST_FILENAME}.

 From the link I posted you can find:

***********example 1, start...
Search pages in more than one directory

RewriteEngine on

#   first try to find it in custom/...
#   ...and if found stop and be happy:
RewriteCond         /your/docroot/dir1/%{REQUEST_FILENAME}  -f
RewriteRule  ^(.+)  /your/docroot/dir1/$1  [L]

#   second try to find it in pub/...
#   ...and if found stop and be happy:
RewriteCond         /your/docroot/dir2/%{REQUEST_FILENAME}  -f
RewriteRule  ^(.+)  /your/docroot/dir2/$1  [L]

#   else go on for other Alias or ScriptAlias directives,
#   etc.
RewriteRule   ^(.+)  -  [PT]
***********...example 1, end

***********example 2, start...
Redirect Failing URLs To Other Webserver

RewriteEngine on
RewriteCond   /your/docroot/%{REQUEST_FILENAME} !-f
RewriteRule   ^(.+)                             http://webserverB.dom/$1
***********...example 2, end

In these examples you will see the usage of


That's not correct.
Suppose the DocumentRoot is /your/docroot

for a request as
%{REQUEST_FILENAME} will be /your/docroot/myfile.php

for a request as
%{REQUEST_FILENAME} will be /your/docroot/path/to/myfile.php

RewriteCond   /your/docroot/%{REQUEST_FILENAME} !-f
means like
RewriteCond   /your/docroot//your/docroot/myfile.php !-f
RewriteCond   /your/docroot//your/docroot/path/to/myfile.php !-f

and that's not correct.

I can illustrate what I said using my log file.
I used these rules:

         RewriteEngine on
         RewriteCond   /usr/www/{REQUEST_FILENAME} !-f
         RewriteRule   ^(.+)$1

my DocumentRoot was "/usr/www/"

I requested:

etc (3) [per-dir /usr/www/] strip per-dir prefix: 
/usr/www/ -> plata.php
etc (3) [per-dir /usr/www/] applying pattern '^(.+)' 
to uri 'plata.php'
etc (4) RewriteCond: 
pattern='!-f' => matched
etc (2) [per-dir /usr/www/] rewrite plata.php ->
etc (2) [per-dir /usr/www/] implicitly forcing 
redirect (rc=302) with
etc (1) [per-dir /usr/www/] escaping for redirect
etc (1) [per-dir /usr/www/] redirect to [REDIRECT/302]

check (4) -->> 

So summing instead of
it was more correct to use
for all the examples I showed.

What do you think ?

Thank you,
Mr Andrea Rossignoli

Hope this is the correct mailing list... :-)

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message