Forum Moderators: phranque
my experience:
I was not able to use
[b]%{DOCUMENT_ROOT}[/b] in my rewrite rules, instead I had to hardcode [b]/path/to/root/[/b], as the two were quite different. I have no idea why [b]%{DOCUMENT_ROOT}[/b] (wrong) is different from PHP's [b]$_SERVER['DOCUMENT_ROOT'][/b] (correct). And [b]%{ENV:DOCUMENT_ROOT}[/b] did not show any value in my case. Maybe this depends on your webspace / server provider.
For debugging purposes I did something like:
RewriteRule ^.*$ test.php?%{DOCUMENT_ROOT}¦%{ENV:DOCUMENT_ROOT} [L]
having test.php just spitting out
$_SERVER['QUERY_STRING']:
<?phpecho strtr($_SERVER['QUERY_STRING'], array("¦" => "<p>", "," => "<br>", "; " => "<br>", "%3A" => ":", "%40" => "@"));?>
(the replacements are mainly for other variables to be formatted neatly like
%{HTTP_COOKIE} etc.) Maybe someone else has any idea.
Good luck.
And, that's when I realized I was taking the wrong approach to the problem. Simply setting the PHP include_path to my root directory, and then only use the directory path relative to the root will of course do it :)
I can't believe I didn't think about that before.
php_value include_path .:/whatever/your/document/root/is
php_value auto_prepend_file path/file.php
Thanks for trying, spyder :)
I've used the following code on several servers with no problems, so I suspect that it *does* depend on your server configuration.
RewriteCond %{QUERY_STRING} ^id=(.+)$
RewriteCond %{DOCUMENT_ROOT}/comm/xyz%1.html -f
RewriteRule ^comm/abc\.html$ /comm/xyz%1.html [L]
RewriteRule ^comm/abc\.html$ - [F]