
rbowen at apache
Nov 12, 2009, 4:00 AM
Post #1 of 1
(189 views)
Permalink
|
|
svn commit: r835356 - in /httpd/httpd/trunk/docs/manual/rewrite: remapping.html.en remapping.xml rewrite_guide.html.en rewrite_guide.xml
|
|
Author: rbowen Date: Thu Nov 12 12:00:32 2009 New Revision: 835356 URL: http://svn.apache.org/viewvc?rev=835356&view=rev Log: Move the 'vhost per user' rule, and add commentary. Modified: httpd/httpd/trunk/docs/manual/rewrite/remapping.html.en httpd/httpd/trunk/docs/manual/rewrite/remapping.xml httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.html.en httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.xml Modified: httpd/httpd/trunk/docs/manual/rewrite/remapping.html.en URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/rewrite/remapping.html.en?rev=835356&r1=835355&r2=835356&view=diff ============================================================================== --- httpd/httpd/trunk/docs/manual/rewrite/remapping.html.en (original) +++ httpd/httpd/trunk/docs/manual/rewrite/remapping.html.en Thu Nov 12 12:00:32 2009 @@ -44,6 +44,7 @@ <li><img alt="" src="../images/down.gif" /> <a href="#archive-access-multiplexer">Redirecting to Geographically Distributed Servers</a></li> <li><img alt="" src="../images/down.gif" /> <a href="#browser-dependent-content">Browser Dependent Content</a></li> <li><img alt="" src="../images/down.gif" /> <a href="#canonicalurl">Canonical URLs</a></li> +<li><img alt="" src="../images/down.gif" /> <a href="#uservhosts">Virtual Hosts Per User</a></li> </ul><h3>See also</h3><ul class="seealso"><li><a href="../mod/mod_rewrite.html">Module documentation</a></li><li><a href="intro.html">mod_rewrite introduction</a></li><li><a href="access.html">Controlling access</a></li><li><a href="advanced.html">Advanced techniques and tricks</a></li><li><a href="avoid.html">When not to use mod_rewrite</a></li></ul></div> <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> <div class="section"> @@ -481,7 +482,62 @@ </dd> </dl> - </div></div> +</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 Hosts Per User</a></h2> + + + + <dl> + <dt>Description:</dt> + + <dd> + <p>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.</p> + + <p>In this recipe, we assume that we'll be using the hostname + <code>www.<strong>username</strong>.example.com</code> for each + user, and serve their content out of + <code>/home/<strong>username</strong>/www</code>.</p> + </dd> + + <dt>Solution:</dt> + + <dd> + +<div class="example"><pre> +RewriteEngine on +RewriteCond %{<strong>HTTP_HOST</strong>} ^www\.<strong>([^.]+)</strong>\.example\.com$ +RewriteRule ^(.*) /home/<strong>%1</strong>/www$1 +</pre></div></dd> + +<dt>Discussion</dt> + <dd> + + <div class="warning">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.</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> + +<p> +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 <code class="module"><a href="../mod/mod_vhost_alias.html">mod_vhost_alias</a></code> instead, as it will much +more gracefully handle anything beyond serving static files, such as any +dynamic content, and Alias resolution. +</p> + </dd> + </dl> + +</div></div> <div class="bottomlang"> <p><span>Available Languages: </span><a href="../en/rewrite/remapping.html" title="English"> en </a></p> </div><div id="footer"> Modified: httpd/httpd/trunk/docs/manual/rewrite/remapping.xml URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/rewrite/remapping.xml?rev=835356&r1=835355&r2=835356&view=diff ============================================================================== --- httpd/httpd/trunk/docs/manual/rewrite/remapping.xml (original) +++ httpd/httpd/trunk/docs/manual/rewrite/remapping.xml Thu Nov 12 12:00:32 2009 @@ -485,7 +485,65 @@ </dd> </dl> - </section> +</section> + +<section id="uservhosts"> + + <title>Virtual Hosts Per User</title> + + <dl> + <dt>Description:</dt> + + <dd> + <p>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.</p> + + <p>In this recipe, we assume that we'll be using the hostname + <code>www.<strong>username</strong>.example.com</code> for each + user, and serve their content out of + <code>/home/<strong>username</strong>/www</code>.</p> + </dd> + + <dt>Solution:</dt> + + <dd> + +<example><pre> +RewriteEngine on +RewriteCond %{<strong>HTTP_HOST</strong>} ^www\.<strong>([^.]+)</strong>\.example\.com$ +RewriteRule ^(.*) /home/<strong>%1</strong>/www$1 +</pre></example></dd> + +<dt>Discussion</dt> + <dd> + + <note type="warning">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.</note> + +<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> + +<p> +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 <module>mod_vhost_alias</module> instead, as it will much +more gracefully handle anything beyond serving static files, such as any +dynamic content, and Alias resolution. +</p> + </dd> + </dl> + +</section> + + Modified: httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.html.en URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.html.en?rev=835356&r1=835355&r2=835356&view=diff ============================================================================== --- httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.html.en (original) +++ httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.html.en Thu Nov 12 12:00:32 2009 @@ -44,7 +44,6 @@ <div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#moveddocroot">Moved <code>DocumentRoot</code></a></li> <li><img alt="" src="../images/down.gif" /> <a href="#trailingslash">Trailing Slash Problem</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 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> @@ -197,46 +196,6 @@ </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 Hosts Per User</a></h2> - - - - <dl> - <dt>Description:</dt> - - <dd> - <p>Assume that you want to provide - <code>www.<strong>username</strong>.host.domain.com</code> - for the homepage of username via just DNS A records to the - same machine and without any virtualhosts on this - machine.</p> - </dd> - - <dt>Solution:</dt> - - <dd> - <p>For HTTP/1.0 requests there is no solution, but for - HTTP/1.1 requests which contain a Host: HTTP header we - can use the following ruleset to rewrite - <code>http://www.username.host.com/anypath</code> - internally to <code>/home/username/anypath</code>:</p> - -<div class="example"><pre> -RewriteEngine on -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> - - </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> -<div class="section"> <h2><a name="redirecthome" id="redirecthome">Redirect Homedirs For Foreigners</a></h2> Modified: httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.xml URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.xml?rev=835356&r1=835355&r2=835356&view=diff ============================================================================== --- httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.xml (original) +++ httpd/httpd/trunk/docs/manual/rewrite/rewrite_guide.xml Thu Nov 12 12:00:32 2009 @@ -189,47 +189,6 @@ </section> - <section id="uservhosts"> - - <title>Virtual Hosts Per User</title> - - <dl> - <dt>Description:</dt> - - <dd> - <p>Assume that you want to provide - <code>www.<strong>username</strong>.host.domain.com</code> - for the homepage of username via just DNS A records to the - same machine and without any virtualhosts on this - machine.</p> - </dd> - - <dt>Solution:</dt> - - <dd> - <p>For HTTP/1.0 requests there is no solution, but for - HTTP/1.1 requests which contain a Host: HTTP header we - can use the following ruleset to rewrite - <code>http://www.username.host.com/anypath</code> - internally to <code>/home/username/anypath</code>:</p> - -<example><pre> -RewriteEngine on -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> - - </section> - <section id="redirecthome"> <title>Redirect Homedirs For Foreigners</title>
|