Differences between revisions 1 and 2
Revision 1 as of 2008-12-31 03:28:55
Size: 1251
Editor: RichBowen
Comment:
Revision 2 as of 2009-09-20 22:13:36
Size: 1248
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 7: Line 7:
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/). 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 [[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/).
Line 13: Line 13:
'''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"]. '''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]].

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 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.

RewriteFlags/PT (last edited 2009-09-20 22:13:36 by localhost)