From 04fde458e50fac13a38ec0a52efee4a94199acc8 Mon Sep 17 00:00:00 2001 From: Eric Covener Date: Sun, 21 Dec 2008 08:08:52 +0000 Subject: Update examples to be more per-directory agnostic, identify examples that 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 | 6 ++++-- docs/manual/rewrite/rewrite_guide.xml | 6 ++++-- docs/manual/rewrite/rewrite_guide_advanced.html.en | 8 ++++++-- docs/manual/rewrite/rewrite_guide_advanced.xml | 8 ++++++-- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/docs/manual/rewrite/rewrite_guide.html.en b/docs/manual/rewrite/rewrite_guide.html.en index 9c29c21997..474ec64389 100644 --- a/docs/manual/rewrite/rewrite_guide.html.en +++ b/docs/manual/rewrite/rewrite_guide.html.en @@ -306,12 +306,12 @@ RewriteEngine on # first try to find it in dir1/... # ...and if found stop and be happy: -RewriteCond %{DOCUMENT_ROOT}/dir1/%{REQUEST_FILENAME} -f +RewriteCond %{DOCUMENT_ROOT}/dir1/%{REQUEST_URI} -f RewriteRule ^(.+) %{DOCUMENT_ROOT}/dir1/$1 [L] # second try to find it in dir2/... # ...and if found stop and be happy: -RewriteCond %{DOCUMENT_ROOT}/dir2/%{REQUEST_FILENAME} -f +RewriteCond %{DOCUMENT_ROOT}/dir2/%{REQUEST_URI} -f RewriteRule ^(.+) %{DOCUMENT_ROOT}/dir2/$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 diff --git a/docs/manual/rewrite/rewrite_guide.xml b/docs/manual/rewrite/rewrite_guide.xml index 2e2f0b9c1d..9c38a9bc9c 100644 --- a/docs/manual/rewrite/rewrite_guide.xml +++ b/docs/manual/rewrite/rewrite_guide.xml @@ -298,12 +298,12 @@ RewriteEngine on # first try to find it in dir1/... # ...and if found stop and be happy: -RewriteCond %{DOCUMENT_ROOT}/dir1/%{REQUEST_FILENAME} -f +RewriteCond %{DOCUMENT_ROOT}/dir1/%{REQUEST_URI} -f RewriteRule ^(.+) %{DOCUMENT_ROOT}/dir1/$1 [L] # second try to find it in dir2/... # ...and if found stop and be happy: -RewriteCond %{DOCUMENT_ROOT}/dir2/%{REQUEST_FILENAME} -f +RewriteCond %{DOCUMENT_ROOT}/dir2/%{REQUEST_URI} -f RewriteRule ^(.+) %{DOCUMENT_ROOT}/dir2/$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 diff --git a/docs/manual/rewrite/rewrite_guide_advanced.html.en b/docs/manual/rewrite/rewrite_guide_advanced.html.en index 9087569538..3f976caa08 100644 --- a/docs/manual/rewrite/rewrite_guide_advanced.html.en +++ b/docs/manual/rewrite/rewrite_guide_advanced.html.en @@ -345,7 +345,7 @@ RewriteRule (.*) netsw-lsdir.cgi/$1
 RewriteEngine on
-RewriteCond   /your/docroot/%{REQUEST_FILENAME} !-f
+RewriteCond   %{DOCUMENT_ROOT/%{REQUEST_URI} !-f
 RewriteRule   ^(.+)                             http://webserverB.dom/$1
 
@@ -575,7 +575,10 @@ RewriteRule ^http://www\.remotesite\.com/(.*)$ /mirror/of/remotesite/$1 through the proxy throughput feature:

-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}       !-f
 RewriteCond %{REQUEST_FILENAME}       !-d
 RewriteRule ^/home/([^/]+)/.www/?(.*) http://www2.quux-corp.dom/~$1/pub/$2 [P]
@@ -850,6 +853,7 @@ HREF="*"
           This is done via the following ruleset:
 
 
+# This example is valid in per-directory context only
 RewriteCond %{REQUEST_FILENAME}   !-s
 RewriteRule ^page\.html$          page.cgi   [T=application/x-httpd-cgi,L]
 
diff --git a/docs/manual/rewrite/rewrite_guide_advanced.xml b/docs/manual/rewrite/rewrite_guide_advanced.xml index 81b026deb2..8534d9dadb 100644 --- a/docs/manual/rewrite/rewrite_guide_advanced.xml +++ b/docs/manual/rewrite/rewrite_guide_advanced.xml @@ -336,7 +336,7 @@ RewriteRule (.*) netsw-lsdir.cgi/$1
 RewriteEngine on
-RewriteCond   /your/docroot/%{REQUEST_FILENAME} !-f
+RewriteCond   %{DOCUMENT_ROOT/%{REQUEST_URI} !-f
 RewriteRule   ^(.+)                             http://webserverB.dom/$1
 
@@ -568,7 +568,10 @@ RewriteRule ^http://www\.remotesite\.com/(.*)$ /mirror/of/remotesite/$1 through the proxy throughput feature:

-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}       !-f
 RewriteCond %{REQUEST_FILENAME}       !-d
 RewriteRule ^/home/([^/]+)/.www/?(.*) http://www2.quux-corp.dom/~$1/pub/$2 [P]
@@ -845,6 +848,7 @@ HREF="*"
           This is done via the following ruleset:
 
 
+# This example is valid in per-directory context only
 RewriteCond %{REQUEST_FILENAME}   !-s
 RewriteRule ^page\.html$          page.cgi   [T=application/x-httpd-cgi,L]
 
-- cgit v1.2.3