]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Update examples to be more per-directory agnostic, identify examples that
authorEric Covener <covener@apache.org>
Sun, 21 Dec 2008 08:08:52 +0000 (08:08 +0000)
committerEric Covener <covener@apache.org>
Sun, 21 Dec 2008 08:08:52 +0000 (08:08 +0000)
seem to be inherently per-directory oriented (REQUEST_URI vs REQUEST_FILENAME)

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@728400 13f79535-47bb-0310-9956-ffa450edef68

docs/manual/rewrite/rewrite_guide.html.en
docs/manual/rewrite/rewrite_guide.xml
docs/manual/rewrite/rewrite_guide_advanced.html.en
docs/manual/rewrite/rewrite_guide_advanced.xml

index 9c29c21997ffc45eea3bedafdd5fec83664e17fc..474ec64389fb7d0f2b48d79f268438ed9ee4e502 100644 (file)
@@ -306,12 +306,12 @@ RewriteEngine on
 
 #   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,
@@ -524,6 +524,8 @@ RewriteBase   /~quux/
 #   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
index 2e2f0b9c1dadd9e4ec5339dd3219acdea1419d2b..9c38a9bc9c5936787f1bece9aeda8252ceb33679 100644 (file)
@@ -298,12 +298,12 @@ RewriteEngine on
 
 #   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,
@@ -517,6 +517,8 @@ RewriteBase   /~quux/
 #   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
index 90875695389651ae84db3bd81f6e61d34897abef..3f976caa0894c03176d7ab67a1bb8bff9b855663 100644 (file)
@@ -345,7 +345,7 @@ RewriteRule   (.*)                     netsw-lsdir.cgi/$1
 
 <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>
 
@@ -575,7 +575,10 @@ RewriteRule   ^http://www\.remotesite\.com/(.*)$ /mirror/of/remotesite/$1
           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>]
@@ -850,6 +853,7 @@ HREF="*"
           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>
index 81b026deb27cca633f3c590e9aebd2e0e121fda0..8534d9dadbceeb3d1d484e2bb063d09bd5f2ace7 100644 (file)
@@ -336,7 +336,7 @@ RewriteRule   (.*)                     netsw-lsdir.cgi/$1
 
 <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>
 
@@ -568,7 +568,10 @@ RewriteRule   ^http://www\.remotesite\.com/(.*)$ /mirror/of/remotesite/$1
           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>]
@@ -845,6 +848,7 @@ HREF="*"
           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>