From: Rich Bowen Date: Thu, 12 Nov 2009 12:00:32 +0000 (+0000) Subject: Move the 'vhost per user' rule, and add commentary. X-Git-Tag: 2.3.4~62 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=118edd63a0b520b01c473e7b5a972b615ab2a763;p=thirdparty%2Fapache%2Fhttpd.git Move the 'vhost per user' rule, and add commentary. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@835356 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/rewrite/remapping.html.en b/docs/manual/rewrite/remapping.html.en index fcb2ba2064c..60f77dead3c 100644 --- a/docs/manual/rewrite/remapping.html.en +++ b/docs/manual/rewrite/remapping.html.en @@ -44,6 +44,7 @@ configuration.
  • Redirecting to Geographically Distributed Servers
  • Browser Dependent Content
  • Canonical URLs
  • +
  • Virtual Hosts Per User
  • See also

    top
    @@ -481,7 +482,62 @@ RewriteRule ^/(puppies|canines)/(.*) /dogs/$2 [R] -
    +
    top
    +
    +

    Virtual Hosts Per User

    + + + +
    +
    Description:
    + +
    +

    We want to automatically create a virtual host for every user who + has an account on our web server system, without having to create + new VirtualHost sections.

    + +

    In this recipe, we assume that we'll be using the hostname + www.username.example.com for each + user, and serve their content out of + /home/username/www.

    +
    + +
    Solution:
    + +
    + +
    +RewriteEngine on
    +RewriteCond   %{HTTP_HOST}        ^www\.([^.]+)\.example\.com$
    +RewriteRule   ^(.*) /home/%1/www$1
    +
    + +
    Discussion
    +
    + +
    You will need to take care of the DNS + resolution - Apache does + not handle name resolution. You'll need either to create CNAME + records for each hostname, or a DNS wildcard record. Creating DNS + records is beyond the scope of this document.
    + +

    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.

    + +

    +As with many techniques discussed in this document, mod_rewrite really +isn't the best way to accomplish this task. You should, instead, +consider using mod_vhost_alias instead, as it will much +more gracefully handle anything beyond serving static files, such as any +dynamic content, and Alias resolution. +

    +
    +
    + +

    Available Languages:  en