mod_vhost_alias.html revision 240a5b8962329911d02566b600be6226e1f857ae
2N/A<html xmlns="http://www.w3.org/TR/xhtml1/strict"><head><!--
2N/AXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
2N/A This file is generated from xml source: DO NOT EDIT
2N/AXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
2N/A--><title>mod_vhost_alias - Apache HTTP Server</title><link rel="stylesheet" type="text/css" href="/style/manual.css"/></head><body><blockquote><div align="center"><img src="/images/sub.gif" alt="[APACHE DOCUMENTATION]"/><h3>Apache HTTP Server Version 2.0</h3></div><h1 align="center">Apache Module mod_vhost_alias</h1><table bgcolor="#cccccc" cellpadding="0" cellspacing="1"><tr><td><table bgcolor="#ffffff"><tr><td valign="top"><span class="help">Description:</span></td><td>Provides for <a href="/vhosts/mass.html">dynamically configured mass virtual
2N/Ahosting</a></td></tr><tr><td><a class="help" href="module-dict.html#Status">Status:</a></td><td>Extension</td></tr><tr><td><a class="help" href="module-dict.html#ModuleIdentifier">Module&nbsp;Identifier:</a></td><td>vhost_alias_module</td></tr></table></td></tr></table><h2>Summary</h2>
2N/A
2N/A <p>This module creates dynamically configured virtual hosts, by
2N/A allowing the IP address and/or the <code>Host:</code> header of
2N/A the HTTP request to be used as part of the pathname to
2N/A determine what files to serve. This allows for easy use of a
2N/A huge number of virtual hosts with similar configurations.</p>
2N/A
2N/A
2N/A<h2>Directives</h2><ul><li><a href="#virtualdocumentroot">VirtualDocumentRoot</a></li><li><a href="#virtualdocumentrootip">VirtualDocumentRootIP</a></li><li><a href="#virtualscriptalias">VirtualScriptAlias</a></li><li><a href="#virtualscriptaliasip">VirtualScriptAliasIP</a></li></ul><p><strong>See also </strong></p><ul><li><a class="directive" href="core.html#usecanonicalname"><code class="directive">UseCanonicalName</code></a>.</li></ul><h2>Directory Name Interpolation</h2>
2N/A
2N/A
2N/A <p>All the directives in this module interpolate a string into
2N/A a pathname. The interpolated string (henceforth called the
2N/A "name") may be either the server name (see the <a href="core.html#usecanonicalname"><code>UseCanonicalName</code></a>
2N/A directive for details on how this is determined) or the IP
2N/A address of the virtual host on the server in dotted-quad
2N/A format. The interpolation is controlled by specifiers inspired
2N/A by <code>printf</code> which have a number of formats:</p>
2N/A
2N/A<table>
2N/A
2N/A<tr><td><code>%%</code></td>
2N/A<td>insert a <code>%</code></td></tr>
2N/A
2N/A<tr><td><code>%p</code></td>
2N/A<td>insert the port number of the virtual host</td></tr>
2N/A
2N/A<tr><td><code>%N.M</code></td>
2N/A<td>insert (part of) the name</td></tr>
2N/A
2N/A</table>
2N/A
2N/A <p><code>N</code> and <code>M</code> are used to specify
2N/A substrings of the name. <code>N</code> selects from the
2N/A dot-separated components of the name, and <code>M</code>
2N/A selects characters within whatever <code>N</code> has selected.
2N/A <code>M</code> is optional and defaults to zero if it isn't
2N/A present; the dot must be present if and only if <code>M</code>
2N/A is present. The interpretation is as follows:</p>
2N/A
2N/A <table>
2N/A <tr><td><code>0</code></td>
2N/A <td>the whole name</td></tr>
2N/A
2N/A <tr><td><code>1</code></td>
2N/A <td>the first part</td></tr>
2N/A
2N/A <tr><td><code>2</code></td>
2N/A <td>the second part</td></tr>
2N/A
2N/A <tr><td><code>-1</code></td>
2N/A <td>the last part</td></tr>
2N/A
2N/A <tr><td><code>-2</code></td>
2N/A <td>the penultimate part</td></tr>
2N/A
2N/A <tr><td><code>2+</code></td>
2N/A <td>the second and all subsequent parts</td></tr>
2N/A
2N/A <tr><td><code>-2+</code></td>
2N/A <td>the penultimate and all preceding parts</td></tr>
2N/A
2N/A <tr><td><code>1+</code> and <code>-1+</code></td>
2N/A <td>the same as <code>0</code></td></tr>
2N/A </table>
2N/A
2N/A <p>If <code>N</code> or <code>M</code> is greater than the number
2N/A of parts available a single underscore is interpolated. </p>
2N/A
2N/A<h2>Examples</h2>
2N/A
2N/A
2N/A <p>For simple name-based virtual hosts you might use the
2N/A following directives in your server configuration file:</p>
2N/A
2N/A<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
2N/A UseCanonicalName Off<br/>
2N/A VirtualDocumentRoot /usr/local/apache/vhosts/%0
2N/A</code></td></tr></table></blockquote>
2N/A
2N/A <p>A request for
2N/A <code>http://www.example.com/directory/file.html</code> will be
2N/A satisfied by the file
2N/A <code>/usr/local/apache/vhosts/www.example.com/directory/file.html</code>.
2N/A </p>
2N/A
2N/A <p>For a very large number of virtual hosts it is a good idea
2N/A to arrange the files to reduce the size of the
2N/A <code>vhosts</code> directory. To do this you might use the
2N/A following in your configuration file:</p>
2N/A
2N/A<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
2N/A UseCanonicalName Off<br/>
2N/A VirtualDocumentRoot /usr/local/apache/vhosts/%3+/%2.1/%2.2/%2.3/%2
2N/A</code></td></tr></table></blockquote>
2N/A
2N/A <p>A request for
2N/A <code>http://www.example.isp.com/directory/file.html</code>
2N/A will be satisfied by the file
2N/A <code>/usr/local/apache/vhosts/isp.com/e/x/a/example/directory/file.html</code>.</p>
2N/A
2N/A <p>A more even spread of files can be achieved by hashing from the
2N/A end of the name, for example: </p>
2N/A
2N/A<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
2N/A VirtualDocumentRoot /usr/local/apache/vhosts/%3+/%2.-1/%2.-2/%2.-3/%2
2N/A</code></td></tr></table></blockquote>
2N/A
2N/A <p>The example request would come from
2N/A <code>/usr/local/apache/vhosts/isp.com/e/l/p/example/directory/file.html</code>.</p>
2N/A
2N/A <p>Alternatively you might use: </p>
2N/A
2N/A<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
2N/A VirtualDocumentRoot /usr/local/apache/vhosts/%3+/%2.1/%2.2/%2.3/%2.4+
2N/A</code></td></tr></table></blockquote>
2N/A
2N/A <p>The example request would come from
2N/A <code>/usr/local/apache/vhosts/isp.com/e/x/a/mple/directory/file.html</code>.</p>
2N/A
2N/A <p>For IP-based virtual hosting you might use the following in
2N/A your configuration file:</p>
2N/A
2N/A<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
2N/A UseCanonicalName DNS<br/>
2N/A VirtualDocumentRootIP /usr/local/apache/vhosts/%1/%2/%3/%4/docs<br/>
2N/A VirtualScriptAliasIP /usr/local/apache/vhosts/%1/%2/%3/%4/cgi-bin
2N/A</code></td></tr></table></blockquote>
2N/A
2N/A <p>A request for
2N/A <code>http://www.example.isp.com/directory/file.html</code>
2N/A would be satisfied by the file
2N/A <code>/usr/local/apache/vhosts/10/20/30/40/docs/directory/file.html</code>
2N/A if the IP address of <code>www.example.com</code> were
2N/A 10.20.30.40. A request for
2N/A <code>http://www.example.isp.com/cgi-bin/script.pl</code> would
2N/A be satisfied by executing the program
2N/A <code>/usr/local/apache/vhosts/10/20/30/40/cgi-bin/script.pl</code>.</p>
2N/A
2N/A <p>If you want to include the <code>.</code> character in a
2N/A <code>VirtualDocumentRoot</code> directive, but it clashes with
2N/A a <code>%</code> directive, you can work around the problem in
2N/A the following way:</p>
2N/A
2N/A<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
2N/A VirtualDocumentRoot /usr/local/apache/vhosts/%2.0.%3.0
2N/A</code></td></tr></table></blockquote>
2N/A
2N/A <p>A request for
2N/A <code>http://www.example.isp.com/directory/file.html</code>
2N/A will be satisfied by the file
2N/A <code>/usr/local/apache/vhosts/example.isp/directory/file.html</code>.</p>
2N/A
2N/A <p>The <a class="directive" href="mod_log_config.html#logformat"><code class="directive">LogFormat</code></a>
2N/A directives <code>%V</code> and <code>%A</code> are useful
2N/A in conjunction with this module.</p>
2N/A<hr/><h2><a name="VirtualDocumentRoot">VirtualDocumentRoot</a> <a name="virtualdocumentroot">Directive</a></h2><table bgcolor="#cccccc" border="0" cellspacing="0" cellpadding="1"><tr><td><table bgcolor="#ffffff"><tr><td><strong>Description: </strong></td><td>Dynamically configure the location of the document root
2N/Afor a given virtual host</td></tr><tr><td><a class="help" href="directive-dict.html#Syntax">Syntax:</a></td><td>VirtualDocumentRoot <em>interpolated-directory</em></td></tr><tr><td><a class="help" href="directive-dict.html#Default">Default:</a></td><td><code>none</code></td></tr><tr><td><a class="help" href="directive-dict.html#Context">Context:</a></td><td>server config, virtual host</td></tr><tr><td><a class="help" href="directive-dict.html#Override">Override:</a></td><td/></tr><tr><td><a class="help" href="directive-dict.html#Status">Status:</a></td><td>Extension</td></tr><tr><td><a class="help" href="directive-dict.html#Module">Module:</a></td><td>mod_vhost_alias</td></tr><tr><td valign="top" align="left"><a class="help" href="directive-dict.html#Compatibility">Compatibility:</a></td><td>VirtualDocumentRoot is only available in 1.3.7 and
2N/Alater.</td></tr></table></td></tr></table>
2N/A
2N/A <p>The <code>VirtualDocumentRoot</code> directive allows you to
2N/A determine where Apache will find your documents based on the
2N/A value of the server name. The result of expanding
2N/A <em>interpolated-directory</em> is used as the root of the
2N/A document tree in a similar manner to the <a class="directive" href="core.html#documentroot"><code class="directive">DocumentRoot</code></a> directive's argument.
2N/A If <em>interpolated-directory</em> is <code>none</code> then
2N/A <code>VirtaulDocumentRoot</code> is turned off. This directive
2N/A cannot be used in the same context as
2N/A <code class="directive">VirtualDocumentRootIP</code>.</p>
2N/A
2N/A<hr/><h2><a name="VirtualDocumentRootIP">VirtualDocumentRootIP</a> <a name="virtualdocumentrootip">Directive</a></h2><table bgcolor="#cccccc" border="0" cellspacing="0" cellpadding="1"><tr><td><table bgcolor="#ffffff"><tr><td><strong>Description: </strong></td><td>Dynamically configure the location of the document root
2N/Afor a given virtual host</td></tr><tr><td><a class="help" href="directive-dict.html#Syntax">Syntax:</a></td><td>VirtualDocumentRootIP <em>interpolated-directory</em></td></tr><tr><td><a class="help" href="directive-dict.html#Default">Default:</a></td><td><code>none</code></td></tr><tr><td><a class="help" href="directive-dict.html#Context">Context:</a></td><td>server config, virtual host</td></tr><tr><td><a class="help" href="directive-dict.html#Override">Override:</a></td><td/></tr><tr><td><a class="help" href="directive-dict.html#Status">Status:</a></td><td>Extension</td></tr><tr><td><a class="help" href="directive-dict.html#Module">Module:</a></td><td>mod_vhost_alias</td></tr><tr><td valign="top" align="left"><a class="help" href="directive-dict.html#Compatibility">Compatibility:</a></td><td>VirtualDocumentRootIP is only available in 1.3.7
2N/Aand later.</td></tr></table></td></tr></table>
2N/A
2N/A<p>The <code>VirtualDocumentRootIP</code> directive is like the
2N/A <code class="directive">VirtualDocumentRoot</code>
2N/A directive, except that it uses the IP address of the server end
2N/A of the connection instead of the server name.</p>
2N/A<hr/><h2><a name="VirtualScriptAlias">VirtualScriptAlias</a> <a name="virtualscriptalias">Directive</a></h2><table bgcolor="#cccccc" border="0" cellspacing="0" cellpadding="1"><tr><td><table bgcolor="#ffffff"><tr><td><strong>Description: </strong></td><td>Dynamically configure the location of the CGI directory for
2N/Aa given virtual host</td></tr><tr><td><a class="help" href="directive-dict.html#Syntax">Syntax:</a></td><td>VirtualScriptAlias <em>interpolated-directory</em></td></tr><tr><td><a class="help" href="directive-dict.html#Default">Default:</a></td><td><code>none</code></td></tr><tr><td><a class="help" href="directive-dict.html#Context">Context:</a></td><td>server config, virtual host</td></tr><tr><td><a class="help" href="directive-dict.html#Override">Override:</a></td><td/></tr><tr><td><a class="help" href="directive-dict.html#Status">Status:</a></td><td>Extension</td></tr><tr><td><a class="help" href="directive-dict.html#Module">Module:</a></td><td>mod_vhost_alias</td></tr><tr><td valign="top" align="left"><a class="help" href="directive-dict.html#Compatibility">Compatibility:</a></td><td>VirtualScriptAlias is only available in 1.3.7
2N/Aand later.</td></tr></table></td></tr></table>
2N/A
2N/A <p>The <code>VirtualScriptAlias</code> directive allows you to
2N/A determine where Apache will find CGI scripts in a similar
2N/A manner to <code class="directive">VirtualDocumentRoot</code>
2N/A does for other documents. It matches requests for URIs starting
2N/A <code>/cgi-bin/</code>, much like <a class="directive" href="mod_alias.html#scriptalias"><code class="directive">ScriptAlias</code></a>
2N/A <code>/cgi-bin/</code> would.</p>
2N/A
2N/A<hr/><h2><a name="VirtualScriptAliasIP">VirtualScriptAliasIP</a> <a name="virtualscriptaliasip">Directive</a></h2><table bgcolor="#cccccc" border="0" cellspacing="0" cellpadding="1"><tr><td><table bgcolor="#ffffff"><tr><td><strong>Description: </strong></td><td>Dynamically configure the location of the cgi directory for
2N/Aa given virtual host</td></tr><tr><td><a class="help" href="directive-dict.html#Syntax">Syntax:</a></td><td>VirtualScriptAliasIP <em>interpolated-directory</em></td></tr><tr><td><a class="help" href="directive-dict.html#Default">Default:</a></td><td><code>none</code></td></tr><tr><td><a class="help" href="directive-dict.html#Context">Context:</a></td><td>server config, virtual host</td></tr><tr><td><a class="help" href="directive-dict.html#Override">Override:</a></td><td/></tr><tr><td><a class="help" href="directive-dict.html#Status">Status:</a></td><td>Extension</td></tr><tr><td><a class="help" href="directive-dict.html#Module">Module:</a></td><td>mod_vhost_alias</td></tr><tr><td valign="top" align="left"><a class="help" href="directive-dict.html#Compatibility">Compatibility:</a></td><td>VirtualScriptAliasIP is only available in 1.3.7
2N/Aand later.</td></tr></table></td></tr></table>
2N/A
2N/A <p>The <code>VirtualScriptAliasIP</code> directive is like the
2N/A <a href="#virtualscriptalias"><code>VirtualScriptAlias</code></a>
2N/A directive, except that it uses the IP address of the server end
2N/A of the connection instead of the server name.</p>
2N/A
2N/A <hr/><h3 align="center">Apache HTTP Server Version 2.0</h3><a href="./"><img src="/images/index.gif" alt="Index"/></a><a href="../"><img src="/images/home.gif" alt="Home"/></a></blockquote></body></html>