From: Rich Bowen Date: Fri, 27 Nov 2009 18:27:26 +0000 (+0000) Subject: Replaces the two-step process with a single rule using the RewriteCond X-Git-Tag: 2.3.5~122 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3d05ffe29ef42cddd6696aa259d70f24244bc484;p=apache Replaces the two-step process with a single rule using the RewriteCond backreference. This technique is far simpler, and far easier to explain to beginners than the unnecessarily complicated technique used. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@884943 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/vhosts/mass.html.en b/docs/manual/vhosts/mass.html.en index a71d154eef..445c4e6ab2 100644 --- a/docs/manual/vhosts/mass.html.en +++ b/docs/manual/vhosts/mass.html.en @@ -356,8 +356,10 @@ RewriteRule ^/(.*)$ /www/hosts/${lowercase:%{SERVER_NAME}}/cgi-bin/$1 [H=cgi-

A Homepages System Using mod_rewrite

-

This does the same thing as the second - example.

+

This is similar to the one above, + but also verifies that the hostname falls into a specific subset of + hostnames - in this case, that it looks like + www.SITE.example.com.

RewriteEngine on
@@ -367,15 +369,11 @@ RewriteMap lowercase int:tolower
# allow CGIs to work
RewriteCond %{REQUEST_URI} !^/cgi-bin/

-# check the hostname is right so that the RewriteRule works
-RewriteCond ${lowercase:%{SERVER_NAME}} ^www\.[a-z-]+\.isp\.com$
+# Capture the site name in the backreference variable %1
+RewriteCond ${lowercase:%{SERVER_NAME}} ^www\.([a-z-]+)\.example\.com$

-# concatenate the virtual host name onto the start of the URI
-# the [C] means do the next rewrite on the result of this one
-RewriteRule ^(.+) ${lowercase:%{SERVER_NAME}}$1 [C]
-
-# now create the real file name
-RewriteRule ^www\.([a-z-]+)\.isp\.com/(.*) /home/$1/$2
+# Map the request to the site's document directory
+RewriteRule ^(.*) /home/%1/$1

# define the global CGI directory
ScriptAlias /cgi-bin/ /www/std-cgi/ diff --git a/docs/manual/vhosts/mass.xml b/docs/manual/vhosts/mass.xml index 9e9c739fff..2107056c73 100644 --- a/docs/manual/vhosts/mass.xml +++ b/docs/manual/vhosts/mass.xml @@ -349,8 +349,10 @@ RewriteRule ^/(.*)$ /www/hosts/${lowercase:%{SERVER_NAME}}/cgi-bin/$1 [H=cgi-

A Homepages System Using <code>mod_rewrite</code> -

This does the same thing as the second - example.

+

This is similar to the one above, + but also verifies that the hostname falls into a specific subset of + hostnames - in this case, that it looks like + www.SITE.example.com.

RewriteEngine on
@@ -360,15 +362,11 @@ RewriteMap lowercase int:tolower
# allow CGIs to work
RewriteCond %{REQUEST_URI} !^/cgi-bin/

-# check the hostname is right so that the RewriteRule works
-RewriteCond ${lowercase:%{SERVER_NAME}} ^www\.[a-z-]+\.isp\.com$
+# Capture the site name in the backreference variable %1
+RewriteCond ${lowercase:%{SERVER_NAME}} ^www\.([a-z-]+)\.example\.com$

-# concatenate the virtual host name onto the start of the URI
-# the [C] means do the next rewrite on the result of this one
-RewriteRule ^(.+) ${lowercase:%{SERVER_NAME}}$1 [C]
-
-# now create the real file name
-RewriteRule ^www\.([a-z-]+)\.isp\.com/(.*) /home/$1/$2
+# Map the request to the site's document directory
+RewriteRule ^(.*) /home/%1/$1

# define the global CGI directory
ScriptAlias /cgi-bin/ /www/std-cgi/ diff --git a/docs/manual/vhosts/mass.xml.ko b/docs/manual/vhosts/mass.xml.ko index f88136f17d..91b22b9176 100644 --- a/docs/manual/vhosts/mass.xml.ko +++ b/docs/manual/vhosts/mass.xml.ko @@ -1,7 +1,7 @@ - + +