Bug 46376 - %{REQUEST_FILENAME} does not hold full local filesystem path to the file or script matching the request
Summary: %{REQUEST_FILENAME} does not hold full local filesystem path to the file or s...
Status: RESOLVED DUPLICATE of bug 16402
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: Documentation (show other bugs)
Version: 2.2-HEAD
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---
Assignee: HTTP Server Documentation List
URL: http://httpd.apache.org/docs/2.2/mod/...
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-10 07:54 UTC by Romain GALLET
Modified: 2008-12-11 05:14 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Romain GALLET 2008-12-10 07:54:49 UTC
In the section RewriteCond Directive, it says:

REQUEST_FILENAME
    The full local filesystem path to the file or script matching the request.

However, this variable seems to hold only the part on the URL after the hostname. Example, in

- http://localhost/images/hotelphotos1/14032.jpg

According to the documentation, with a DocumentRoot of "/var/www/html", you would expect %{REQUEST_FILENAME} to be

- /var/www/html/images/hotelphotos1/14032.jpg

But it really is just:

- /images/hotelphotos1/14032.jpg

How to prove/reproduce:
- Apache 2.2.10 (ArchLinux official package)
- In the vhost config, I have one and only one rule:
  RewriteRule (.*) http://www.google.com/?test=%{REQUEST_FILENAME} [L]

Using the URL http://localhost/images/hotelphotos1/14032.jpg, I get

http://www.google.com/?test=/images/hotelphotos1/14032.jpg

which shows that %{REQUEST_FILENAME} is NOT the full local filesystem path to 14032.jpg.

This is an issue because RewriteCond testing for the presence of a file, ie RewriteCond %{REQUEST_FILENAME} -f will always return False.

It can be circumvented using

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -f

I could reproduce this bug/behavior on CentOS5 and the latest Apache2 rpm.

To be, this behavoir makes sense. It'd rather need a change in the documentation for that feature.

Regards.
Comment 1 Bob Ionescu 2008-12-11 05:14:05 UTC

*** This bug has been marked as a duplicate of bug 16402 ***