From: Rich Bowen Date: Wed, 13 Aug 2008 01:49:22 +0000 (+0000) Subject: I've long hated this technique, in which the hostname is prepended to X-Git-Tag: 2.3.0~368 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9f8ccad39aba0c4b83317741d9de2a7ca562091a;p=apache 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 --- diff --git a/docs/manual/rewrite/rewrite_guide.html.en b/docs/manual/rewrite/rewrite_guide.html.en index c571fcbac5..b1b4d27330 100644 --- a/docs/manual/rewrite/rewrite_guide.html.en +++ b/docs/manual/rewrite/rewrite_guide.html.en @@ -47,7 +47,7 @@
  • Move Homedirs to Different Webserver
  • Search for pages in more than one directory
  • Set Environment Variables According To URL Parts
  • -
  • Virtual User Hosts
  • +
  • Virtual Hosts Per User
  • Redirect Homedirs For Foreigners
  • Redirecting Anchors
  • Time-Dependent Rewriting
  • @@ -356,7 +356,7 @@ RewriteRule ^(.*)/S=([^/]+)/(.*) $1/$3 [E=STATUS:$
    top
    -

    Virtual User Hosts

    +

    Virtual Hosts Per User

    @@ -382,10 +382,15 @@ RewriteRule ^(.*)/S=([^/]+)/(.*) $1/$3 [E=STATUS:$
     RewriteEngine on
    -RewriteCond   %{HTTP_HOST}                 ^www\.[^.]+\.host\.com$
    -RewriteRule   ^(.+)                        %{HTTP_HOST}$1          [C]
    -RewriteRule   ^www\.([^.]+)\.host\.com(.*) /home/$1$2
    +RewriteCond   %{HTTP_HOST}                 ^www\.([^.]+)\.host\.com$
    +RewriteRule   ^(.*) /home/%1$1
     
    + +

    Parentheses used in a RewriteCond are captured into the +backreferences %1, %2, etc, while parentheses +used in RewriteRule are +captured into the backreferences $1, $2, +etc.

    diff --git a/docs/manual/rewrite/rewrite_guide.xml b/docs/manual/rewrite/rewrite_guide.xml index 8b55dcf9d7..6139812cf7 100644 --- a/docs/manual/rewrite/rewrite_guide.xml +++ b/docs/manual/rewrite/rewrite_guide.xml @@ -350,7 +350,7 @@ RewriteRule ^(.*)/S=([^/]+)/(.*) $1/$3 [E=STATUS:$
    - Virtual User Hosts + Virtual Hosts Per User
    Description:
    @@ -374,10 +374,16 @@ RewriteRule ^(.*)/S=([^/]+)/(.*) $1/$3 [E=STATUS:$
     RewriteEngine on
    -RewriteCond   %{HTTP_HOST}                 ^www\.[^.]+\.host\.com$
    -RewriteRule   ^(.+)                        %{HTTP_HOST}$1          [C]
    -RewriteRule   ^www\.([^.]+)\.host\.com(.*) /home/$1$2
    +RewriteCond   %{HTTP_HOST}                 ^www\.([^.]+)\.host\.com$
    +RewriteRule   ^(.*) /home/%1$1
     
    + +

    Parentheses used in a RewriteCond are captured into the +backreferences %1, %2, etc, while parentheses +used in RewriteRule are +captured into the backreferences $1, $2, +etc.