]> granicus.if.org Git - apache/commitdiff
I've long hated this technique, in which the hostname is prepended to
authorRich Bowen <rbowen@apache.org>
Wed, 13 Aug 2008 01:49:22 +0000 (01:49 +0000)
committerRich Bowen <rbowen@apache.org>
Wed, 13 Aug 2008 01:49:22 +0000 (01:49 +0000)
the REQUEST_URI, and then munged on a second pass through. It's
confusing, hard to explain to beginners, and completely unnecessary. Use
RewriteCond backreferences instead.

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

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

index c571fcbac5f0f3c489a4d1849f486ca28369a4a0..b1b4d273309d275122bde60ff0746846a9b8e1d7 100644 (file)
@@ -47,7 +47,7 @@
 <li><img alt="" src="../images/down.gif" /> <a href="#movehomedirs">Move Homedirs to Different Webserver</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#multipledirs">Search for pages in more than one directory</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#setenvvars">Set Environment Variables According To URL Parts</a></li>
-<li><img alt="" src="../images/down.gif" /> <a href="#uservhosts">Virtual User Hosts</a></li>
+<li><img alt="" src="../images/down.gif" /> <a href="#uservhosts">Virtual Hosts Per User</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#redirecthome">Redirect Homedirs For Foreigners</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#redirectanchors">Redirecting Anchors</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#time-dependent">Time-Dependent Rewriting</a></li>
@@ -356,7 +356,7 @@ RewriteRule   ^(.*)/<strong>S=([^/]+)</strong>/(.*)    $1/$3 [E=<strong>STATUS:$
 
     </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
-<h2><a name="uservhosts" id="uservhosts">Virtual User Hosts</a></h2>
+<h2><a name="uservhosts" id="uservhosts">Virtual Hosts Per User</a></h2>
 
       
 
@@ -382,10 +382,15 @@ RewriteRule   ^(.*)/<strong>S=([^/]+)</strong>/(.*)    $1/$3 [E=<strong>STATUS:$
 
 <div class="example"><pre>
 RewriteEngine on
-RewriteCond   %{<strong>HTTP_HOST</strong>}                 ^www\.<strong>[^.]+</strong>\.host\.com$
-RewriteRule   ^(.+)                        %{HTTP_HOST}$1          [C]
-RewriteRule   ^www\.<strong>([^.]+)</strong>\.host\.com(.*) /home/<strong>$1</strong>$2
+RewriteCond   %{<strong>HTTP_HOST</strong>}                 ^www\.<strong>([^.]+)</strong>\.host\.com$
+RewriteRule   ^(.*) /home/<strong>%1</strong>$1
 </pre></div>
+
+<p>Parentheses used in a <code class="directive"><a href="../mod/mod_rewrite.html#rewritecond">RewriteCond</a></code> are captured into the
+backreferences <code>%1</code>, <code>%2</code>, etc, while parentheses
+used in <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> are
+captured into the backreferences <code>$1</code>, <code>$2</code>,
+etc.</p>
         </dd>
       </dl>
 
index 8b55dcf9d76f403de3ce1751cf52de07ab217c9c..6139812cf7b22f5ba40643bbc5d74cd287f8ec70 100644 (file)
@@ -350,7 +350,7 @@ RewriteRule   ^(.*)/<strong>S=([^/]+)</strong>/(.*)    $1/$3 [E=<strong>STATUS:$
 
     <section id="uservhosts">
 
-      <title>Virtual User Hosts</title>
+      <title>Virtual Hosts Per User</title>
 
       <dl>
         <dt>Description:</dt>
@@ -374,10 +374,16 @@ RewriteRule   ^(.*)/<strong>S=([^/]+)</strong>/(.*)    $1/$3 [E=<strong>STATUS:$
 
 <example><pre>
 RewriteEngine on
-RewriteCond   %{<strong>HTTP_HOST</strong>}                 ^www\.<strong>[^.]+</strong>\.host\.com$
-RewriteRule   ^(.+)                        %{HTTP_HOST}$1          [C]
-RewriteRule   ^www\.<strong>([^.]+)</strong>\.host\.com(.*) /home/<strong>$1</strong>$2
+RewriteCond   %{<strong>HTTP_HOST</strong>}                 ^www\.<strong>([^.]+)</strong>\.host\.com$
+RewriteRule   ^(.*) /home/<strong>%1</strong>$1
 </pre></example>
+
+<p>Parentheses used in a <directive
+module="mod_rewrite">RewriteCond</directive> are captured into the
+backreferences <code>%1</code>, <code>%2</code>, etc, while parentheses
+used in <directive module="mod_rewrite">RewriteRule</directive> are
+captured into the backreferences <code>$1</code>, <code>$2</code>,
+etc.</p>
         </dd>
       </dl>