# first try to find it in dir1/...
# ...and if found stop and be happy:
-RewriteCond %{DOCUMENT_ROOT}/<strong>dir1</strong>/%{REQUEST_FILENAME} -f
+RewriteCond %{DOCUMENT_ROOT}/<strong>dir1</strong>/%{REQUEST_URI} -f
RewriteRule ^(.+) %{DOCUMENT_ROOT}/<strong>dir1</strong>/$1 [L]
# second try to find it in dir2/...
# ...and if found stop and be happy:
-RewriteCond %{DOCUMENT_ROOT}/<strong>dir2</strong>/%{REQUEST_FILENAME} -f
+RewriteCond %{DOCUMENT_ROOT}/<strong>dir2</strong>/%{REQUEST_URI} -f
RewriteRule ^(.+) %{DOCUMENT_ROOT}/<strong>dir2</strong>/$1 [L]
# else go on for other Alias or ScriptAlias directives,
# parse out basename, but remember the fact
RewriteRule ^(.*)\.html$ $1 [C,E=WasHTML:yes]
# rewrite to document.phtml if exists
+# Note: This is a per-directory example, so %{REQUEST_FILENAME} is the full
+# filesystem path as already mapped by the server.
RewriteCond %{REQUEST_FILENAME}.phtml -f
RewriteRule ^(.*)$ $1.phtml [S=1]
# else reverse the previous basename cutout
# first try to find it in dir1/...
# ...and if found stop and be happy:
-RewriteCond %{DOCUMENT_ROOT}/<strong>dir1</strong>/%{REQUEST_FILENAME} -f
+RewriteCond %{DOCUMENT_ROOT}/<strong>dir1</strong>/%{REQUEST_URI} -f
RewriteRule ^(.+) %{DOCUMENT_ROOT}/<strong>dir1</strong>/$1 [L]
# second try to find it in dir2/...
# ...and if found stop and be happy:
-RewriteCond %{DOCUMENT_ROOT}/<strong>dir2</strong>/%{REQUEST_FILENAME} -f
+RewriteCond %{DOCUMENT_ROOT}/<strong>dir2</strong>/%{REQUEST_URI} -f
RewriteRule ^(.+) %{DOCUMENT_ROOT}/<strong>dir2</strong>/$1 [L]
# else go on for other Alias or ScriptAlias directives,
# parse out basename, but remember the fact
RewriteRule ^(.*)\.html$ $1 [C,E=WasHTML:yes]
# rewrite to document.phtml if exists
+# Note: This is a per-directory example, so %{REQUEST_FILENAME} is the full
+# filesystem path as already mapped by the server.
RewriteCond %{REQUEST_FILENAME}.phtml -f
RewriteRule ^(.*)$ $1.phtml [S=1]
# else reverse the previous basename cutout
<div class="example"><pre>
RewriteEngine on
-RewriteCond /your/docroot/%{REQUEST_FILENAME} <strong>!-f</strong>
+RewriteCond %{DOCUMENT_ROOT/%{REQUEST_URI} <strong>!-f</strong>
RewriteRule ^(.+) http://<strong>webserverB</strong>.dom/$1
</pre></div>
through the proxy throughput feature:</p>
<div class="example"><pre>
-RewriteRule ^/~([^/]+)/?(.*) /home/$1/.www/$2
+RewriteRule ^/~([^/]+)/?(.*) /home/$1/.www/$2 [C]
+# REQUEST_FILENAME usage below is correct in this per-server context example
+# because the rule that references REQUEST_FILENAME is chained to a rule that
+# sets REQUEST_FILENAME.
RewriteCond %{REQUEST_FILENAME} <strong>!-f</strong>
RewriteCond %{REQUEST_FILENAME} <strong>!-d</strong>
RewriteRule ^/home/([^/]+)/.www/?(.*) http://<strong>www2</strong>.quux-corp.dom/~$1/pub/$2 [<strong>P</strong>]
This is done via the following ruleset:
<div class="example"><pre>
+# This example is valid in per-directory context only
RewriteCond %{REQUEST_FILENAME} <strong>!-s</strong>
RewriteRule ^page\.<strong>html</strong>$ page.<strong>cgi</strong> [T=application/x-httpd-cgi,L]
</pre></div>
<example><pre>
RewriteEngine on
-RewriteCond /your/docroot/%{REQUEST_FILENAME} <strong>!-f</strong>
+RewriteCond %{DOCUMENT_ROOT/%{REQUEST_URI} <strong>!-f</strong>
RewriteRule ^(.+) http://<strong>webserverB</strong>.dom/$1
</pre></example>
through the proxy throughput feature:</p>
<example><pre>
-RewriteRule ^/~([^/]+)/?(.*) /home/$1/.www/$2
+RewriteRule ^/~([^/]+)/?(.*) /home/$1/.www/$2 [C]
+# REQUEST_FILENAME usage below is correct in this per-server context example
+# because the rule that references REQUEST_FILENAME is chained to a rule that
+# sets REQUEST_FILENAME.
RewriteCond %{REQUEST_FILENAME} <strong>!-f</strong>
RewriteCond %{REQUEST_FILENAME} <strong>!-d</strong>
RewriteRule ^/home/([^/]+)/.www/?(.*) http://<strong>www2</strong>.quux-corp.dom/~$1/pub/$2 [<strong>P</strong>]
This is done via the following ruleset:
<example><pre>
+# This example is valid in per-directory context only
RewriteCond %{REQUEST_FILENAME} <strong>!-s</strong>
RewriteRule ^page\.<strong>html</strong>$ page.<strong>cgi</strong> [T=application/x-httpd-cgi,L]
</pre></example>