Bug 16402 - %{REQUEST_FILENAME} needs lookahead in order to contain local path instead of URI
Summary: %{REQUEST_FILENAME} needs lookahead in order to contain local path instead of...
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: Documentation (show other bugs)
Version: 2.5-HEAD
Hardware: All All
: P3 enhancement with 3 votes (vote)
Target Milestone: ---
Assignee: HTTP Server Documentation List
: 45280 46376 (view as bug list)
Depends on:
Reported: 2003-01-24 18:29 UTC by John Morrissey
Modified: 2010-03-17 20:09 UTC (History)
3 users (show)


Note You need to log in before you can comment on or make changes to this bug.
Description John Morrissey 2003-01-24 18:29:42 UTC
I'm running Apache2 (2.0.43) and wanted to transparently send requests for
PHP-processed files to an Apache1.3 instance, which runs PHP Accelerator
(www.php-accelerator.co.uk). Naturally, I turned to mod_proxy and mod_rewrite.
However, I (think I've) found a problem with either the docs or with mod_rewrite
itself. Here's the ruleset I tried:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} \.php$
RewriteRule ^/+(.*)$ http://otherhost.horde.net/$1 [P,NE,L]

Turning on a RewriteLog showed that %{REQUEST_FILENAME} contained the URI of the
request, not the full local path as stated in the mod_rewrite docs
(http://httpd.apache.org/docs-2.0/mod/mod_rewrite.html). However, I found that
this ruleset works:

RewriteEngine on
RewriteCond %{LA-U:REQUEST_FILENAME} \.php$
RewriteRule ^/+(.*)$ http://otherhost.horde.net/$1 [P,NE,L]

In order to get the full local path in %{REQUEST_FILENAME}, you have to force
mod_rewrite to do a look-ahead with %{LA-U:REQUEST_FILENAME}.

The kicker is that the docs go on at length about the difference between
REQUEST_URI and REQUEST_FILENAME. I found these variables to be identical unless
you force mod_rewrite to look ahead for REQUEST_FILENAME. I posted to
apache-users, but didn't get any response after a few days and this doesn't seem
to be reported already. Is this a bug in the docs, mod_rewrite, or am I just
blowing hot air?
Comment 1 André Malo 2003-01-31 15:18:03 UTC
Okay, we should really better explain, when what variable is actually available,
especially because it differs for server and directory context rules.

...it goes on my todo (if nobody else beats me before) ;-)

Thanks for using Apache!
Comment 2 Bob Ionescu 2008-12-11 05:14:05 UTC
*** Bug 46376 has been marked as a duplicate of this bug. ***
Comment 3 Bob Ionescu 2008-12-14 05:38:52 UTC
*** Bug 45280 has been marked as a duplicate of this bug. ***
Comment 4 Stefan Fritsch 2010-03-17 19:19:01 UTC
Is the clarification added by Eric Covener in r914980 / PR48796 enough to close this PR?
Comment 5 John Morrissey 2010-03-17 20:09:45 UTC
Works for me.

(Seems like RESOLVED/FIXED is ok? Either that or RESOLVED/DUPLICATE of 48796.)