Dear Wiki user, You have subscribed to a wiki page or wiki category on "Httpd Wiki" for change notification.
The following page has been changed by EricCovener: http://wiki.apache.org/httpd/RewriteContext ------------------------------------------------------------------------------ == Environment Variables == - As mentioned, in !VirtualHost (per-server) context, rewrite rules run before the request has been mapped to a filesystem path. Resulting from this, certain of the variables available to mod_rewrite concerned with filesystem paths are incomplete, including SCRIPT_FILENAME (and its mirror, REQUEST_FILENAME). + As mentioned, in !VirtualHost (per-server) context, rewrite rules run before the request has been mapped to a filesystem path. Resulting from this, certain of the variables available to mod_rewrite concerned with filesystem paths are incomplete, including SCRIPT_FILENAME (and its mirror, REQUEST_FILENAME). During !VirtualHost (per-server) context, these variables contain a copy of REQUEST_URI, as opposed to their ultimate filesystem path values. + + Conceptually, since *_FILENAME haven't been decided in per-server context, you should probably avoid using them in this context and just use REQUEST_URI. As an example, the following two rulesets attempt to see if the request uri corresponds to an existing file and take action if not. {{{ - # in .htaccess, SCRIPT_FILENAME is complete + # in .htaccess, SCRIPT_FILENAME is a complete _filesystem_ path RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule (.*) script.cgi }}} {{{ - # in VirtualHost, SCRIPT_FILENAME is incomplete + # in VirtualHost, SCRIPT_FILENAME is incomplete, so this ruleset SHOULD just use REQUEST_URI + # to see where this URI _may_ have been mapped in the filesystem RewriteEngine On RewriteCond %{DOCUMENT_ROOT}/%{SCRIPT_FILENAME} !-f RewriteRule (.*) /script.cgi }}} - In particular, in per-server context the SCRIPT_FILENAME variable will be the same as REQUEST_URI. (FIXME: is this correct?) -
