diff options
Diffstat (limited to 'docs/manual/rewrite/vhosts.html.en')
-rw-r--r-- | docs/manual/rewrite/vhosts.html.en | 155 |
1 files changed, 90 insertions, 65 deletions
diff --git a/docs/manual/rewrite/vhosts.html.en b/docs/manual/rewrite/vhosts.html.en index dd509c46..9f9d0aa1 100644 --- a/docs/manual/rewrite/vhosts.html.en +++ b/docs/manual/rewrite/vhosts.html.en @@ -8,10 +8,13 @@ <title>Dynamic mass virtual hosts with mod_rewrite - Apache HTTP Server</title> <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> -<link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /> +<link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" /> +<script src="../style/scripts/prettify.js" type="text/javascript"> +</script> + <link href="../images/favicon.ico" rel="shortcut icon" /></head> <body id="manual-page"><div id="page-header"> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p> +<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p> <p class="apache">Apache HTTP Server Version 2.4</p> <img alt="" src="../images/feather.gif" /></div> <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div> @@ -37,7 +40,7 @@ mod_rewrite</a> document.</div> <li><img alt="" src="../images/down.gif" /> <a href="#simple.rewrite">Dynamic Virtual Hosts Using <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code></a></li> <li><img alt="" src="../images/down.gif" /> <a href="#xtra-conf">Using a Separate Virtual Host Configuration File</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="remapping.html">Redirection and remapping</a></li><li><a href="access.html">Controlling access</a></li><li><a href="proxy.html">Proxying</a></li><li><a href="rewritemap.html">RewriteMap</a></li><li><a href="advanced.html">Advanced techniques</a></li><li><a href="avoid.html">When not to use mod_rewrite</a></li></ul></div> +</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="remapping.html">Redirection and remapping</a></li><li><a href="access.html">Controlling access</a></li><li><a href="proxy.html">Proxying</a></li><li><a href="rewritemap.html">RewriteMap</a></li><li><a href="advanced.html">Advanced techniques</a></li><li><a href="avoid.html">When not to use mod_rewrite</a></li></ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div> <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> <div class="section"> <h2><a name="per-hostname" id="per-hostname">Virtual Hosts For Arbitrary Hostnames</a></h2> @@ -62,14 +65,15 @@ mod_rewrite</a> document.</div> <dd> -<div class="example"><p><code> -RewriteEngine on<br /> -<br /> -RewriteMap lowercase int:tolower<br /> -<br /> -RewriteCond %{lowercase:%{<strong>HTTP_HOST</strong>}} ^www\.<strong>([^.]+)</strong>\.example\.com$<br /> +<pre class="prettyprint lang-config"> +RewriteEngine on + +RewriteMap lowercase int:tolower + +RewriteCond ${lowercase:%{<strong>HTTP_HOST</strong>}} ^www\.<strong>([^.]+)</strong>\.example\.com$ RewriteRule ^(.*) /home/<strong>%1</strong>/www$1 -</code></p></div></dd> +</pre> +</dd> <dt>Discussion</dt> <dd> @@ -119,39 +123,38 @@ dynamic content, and Alias resolution. any <code>ScriptAlias</code> directives, we must have <code>mod_rewrite</code> explicitly enact those mappings.</p> -<div class="example"><p><code> -# get the server name from the Host: header<br /> -UseCanonicalName Off<br /> -<br /> -# splittable logs<br /> -LogFormat "%{Host}i %h %l %u %t \"%r\" %s %b" vcommon<br /> -CustomLog logs/access_log vcommon<br /> -<br /> -<Directory /www/hosts><br /> -<span class="indent"> - # ExecCGI is needed here because we can't force<br /> - # CGI execution in the way that ScriptAlias does<br /> - Options FollowSymLinks ExecCGI<br /> -</span> -</Directory><br /> -<br /> -RewriteEngine On<br /> -<br /> -# a ServerName derived from a Host: header may be any case at all<br /> -RewriteMap lowercase int:tolower<br /> -<br /> -## deal with normal documents first:<br /> -# allow Alias /icons/ to work - repeat for other aliases<br /> -RewriteCond %{REQUEST_URI} !^/icons/<br /> -# allow CGIs to work<br /> -RewriteCond %{REQUEST_URI} !^/cgi-bin/<br /> -# do the magic<br /> -RewriteRule ^/(.*)$ /www/hosts/${lowercase:%{SERVER_NAME}}/docs/$1<br /> -<br /> -## and now deal with CGIs - we have to force a handler<br /> -RewriteCond %{REQUEST_URI} ^/cgi-bin/<br /> -RewriteRule ^/(.*)$ /www/hosts/${lowercase:%{SERVER_NAME}}/cgi-bin/$1 [H=cgi-script]<br /> -</code></p></div> +<pre class="prettyprint lang-config"> +# get the server name from the Host: header +UseCanonicalName Off + +# splittable logs +LogFormat "%{Host}i %h %l %u %t \"%r\" %s %b" vcommon +CustomLog logs/access_log vcommon + +<Directory /www/hosts> + # ExecCGI is needed here because we can't force + # CGI execution in the way that ScriptAlias does + Options FollowSymLinks ExecCGI +</Directory> + +RewriteEngine On + +# a ServerName derived from a Host: header may be any case at all +RewriteMap lowercase int:tolower + +## deal with normal documents first: +# allow Alias /icons/ to work - repeat for other aliases +RewriteCond %{REQUEST_URI} !^/icons/ +# allow CGIs to work +RewriteCond %{REQUEST_URI} !^/cgi-bin/ +# do the magic +RewriteRule ^/(.*)$ /www/hosts/${lowercase:%{SERVER_NAME}}/docs/$1 + +## and now deal with CGIs - we have to force a handler +RewriteCond %{REQUEST_URI} ^/cgi-bin/ +RewriteRule ^/(.*)$ /www/hosts/${lowercase:%{SERVER_NAME}}/cgi-bin/$1 [H=cgi-script] +</pre> + </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div> <div class="section"> @@ -174,32 +177,54 @@ customer-N.example.com /www/customers/N<br /> <p>The <code>httpd.conf</code> should contain the following:</p> -<div class="example"><p><code> -RewriteEngine on<br /> -<br /> -RewriteMap lowercase int:tolower<br /> -<br /> -# define the map file<br /> -RewriteMap vhost txt:/www/conf/vhost.map<br /> -<br /> -# deal with aliases as above<br /> -RewriteCond %{REQUEST_URI} !^/icons/<br /> -RewriteCond %{REQUEST_URI} !^/cgi-bin/<br /> -RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$<br /> -# this does the file-based remap<br /> -RewriteCond ${vhost:%1} ^(/.*)$<br /> -RewriteRule ^/(.*)$ %1/docs/$1<br /> -<br /> -RewriteCond %{REQUEST_URI} ^/cgi-bin/<br /> -RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$<br /> -RewriteCond ${vhost:%1} ^(/.*)$<br /> +<pre class="prettyprint lang-config"> +RewriteEngine on + +RewriteMap lowercase int:tolower + +# define the map file +RewriteMap vhost txt:/www/conf/vhost.map + +# deal with aliases as above +RewriteCond %{REQUEST_URI} !^/icons/ +RewriteCond %{REQUEST_URI} !^/cgi-bin/ +RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$ +# this does the file-based remap +RewriteCond ${vhost:%1} ^(/.*)$ +RewriteRule ^/(.*)$ %1/docs/$1 + +RewriteCond %{REQUEST_URI} ^/cgi-bin/ +RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$ +RewriteCond ${vhost:%1} ^(/.*)$ RewriteRule ^/(.*)$ %1/cgi-bin/$1 [H=cgi-script] -</code></p></div> +</pre> + </div></div> <div class="bottomlang"> <p><span>Available Languages: </span><a href="../en/rewrite/vhosts.html" title="English"> en </a></p> -</div><div id="footer"> +</div><div class="top"><a href="#page-header"><img src="../images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div> +<script type="text/javascript"><!--//--><![CDATA[//><!-- +var comments_shortname = 'httpd'; +var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/vhosts.html'; +(function(w, d) { + if (w.location.hostname.toLowerCase() == "httpd.apache.org") { + d.write('<div id="comments_thread"><\/div>'); + var s = d.createElement('script'); + s.type = 'text/javascript'; + s.async = true; + s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; + (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); + } + else { + d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); + } +})(window, document); +//--><!]]></script></div><div id="footer"> <p class="apache">Copyright 2012 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> -<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div> +<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- +if (typeof(prettyPrint) !== 'undefined') { + prettyPrint(); +} +//--><!]]></script> </body></html>
\ No newline at end of file |