Commit cd40b5e2 authored by Richard Bowen's avatar Richard Bowen
Browse files

I've long hated this technique, in which the hostname is prepended to

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
parent d9627d35
Loading
Loading
Loading
Loading
+10 −5
Changes for docs/manual/rewrite/rewrite_guide.html.en: 10 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -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>

+10 −4
Changes for docs/manual/rewrite/rewrite_guide.xml: 10 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -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>