Bug 45280

Summary: REQUEST_FILENAME is not full local filesystem path
Product: Apache httpd-2 Reporter: Edwin Martin <edwin>
Component: mod_rewriteAssignee: Apache HTTPD Bugs Mailing List <bugs>
Status: RESOLVED DUPLICATE    
Severity: normal CC: rse
Priority: P2    
Version: 2.2.8   
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   

Description Edwin Martin 2008-06-25 14:05:38 UTC
According to the documentation on http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html, the variable REQUEST_FILENAME is the full local filesystem path:

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

This seems not to be the case.

It seems the variable should be prefixed with DOCUMENT_ROOT to get the full path.

Examples:
This does not trigger the rule:
RewriteCond %{REQUEST_FILENAME} -s

But this does:
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -s

Please update the documentation or the implementation.

I lost several hours over this and I guess I'm not the only one.
Comment 1 Bob Ionescu 2008-08-14 02:56:18 UTC
The value of REQUEST_FILENAME depends upon context. It contains the full physical path only, if the request has already been mapped to the file system (-> directory context). That's not the case if you're using mod_rewrite in per-server context – you're still on uri-level. The full physical path is simply unknown in this state of processing.
To get the full physical path in server-context, you'll need an internal sub-request (%LA-U or %LA-F). Prefixing with document_root is not a solution, because this may not be the physical path at the end (think about aliases, mod_userdir etc.).

May be the docs should state that more clearly, but not the quoted 1.3 ones.
Comment 2 Bob Ionescu 2008-12-14 05:38:52 UTC

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