You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wiki-changes@httpd.apache.org by Apache Wiki <wi...@apache.org> on 2008/12/31 04:28:56 UTC
[Httpd Wiki] Update of "RewriteFlags/PT" by RichBowen
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 RichBowen:
http://wiki.apache.org/httpd/RewriteFlags/PT
New page:
The PT-Flag forces the substitution to be handled as an URL-path and not a filesystem path. Let's try to explain that with an example:
{{{
RewriteRule ^/([^.]+)\.html$ /$1.php [PT]
}}}
Let's assume a request of /test/foo.html. The result of that single rule (even with out the PT-Flag) would be of course /test/foo.php. But if all rules are being processed (or the [wiki:Flags/L L-Flag] was used), mod_rewrite will automatically prefix the result /test/foo.php with the DOCUMENT_ROOT, if /test/ is not an existing filesystem path (like /etc/).
So the result from mod_rewrite is now a filesystem path /var/www/test/foo.php and not an URL-path. This makes it impossible to apply any further Aliases from mod_alias or user dirs from mod_userdir. Now, if you use the PT-Flag the result of mod_rewrite will remain /test/foo.php as an URL-path, so Aliases can still be processed.
Speaking in technical words: mod_rewrite does not perform a uri-to-filename translation, the request is not mapped on the filesystem by mod_rewrite. It remains on the URL level.
'''Note:''' The PT-Flag implies the L-Flag, so the processing stopps immediatelly. The PT-Flag is only usefull in ["per-server context"] and will be ignored in ["per-dir context"].