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.

  • No labels