161N/A<!
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
161N/A<
TITLE>Apache module mod_vhost_alias</
TITLE>
161N/A<!-- Background white, links blue (unvisited), navy (visited), red (active) --> 161N/A Apache HTTP Server Version 1.3
161N/A<
H1 ALIGN="CENTER">Module mod_vhost_alias</
H1>
161N/Aand is not compiled in by default. It provides support for
161N/A<
H2>Directory Name Interpolation</
H2>
618N/AAll the directives in this module interpolate a string into a
161N/Apathname. The interpolated string (henceforth called the "name") may
161N/Abe either the server name (see the
844N/A<
A HREF="core.html#usecanonicalname"><
CODE>UseCanonicalName</
CODE></
A>
844N/Adirective for details on how this is determined) or the IP address of
161N/Athe virtual host on the server in dotted-quad format. The
1273N/Ainterpolation is controlled by specifiers inspired by
161N/A<
CODE>printf</
CODE> which have a number of formats:
161N/A <
DD>insert a <
CODE>%</
CODE>
161N/A <
DD>insert the port number of the virtual host
161N/A <
DD>insert (part of) the name
161N/A<
CODE>N</
CODE> and <
CODE>M</
CODE> are used to specify substrings of
161N/Athe name. <
CODE>N</
CODE> selects from the dot-separated components of
161N/Athe name, and <
CODE>M</
CODE> selects characters within whatever
161N/A<
CODE>N</
CODE> has selected. <
CODE>M</
CODE> is optional and defaults
161N/Ato zero if it isn't present; the dot must be present if and only if
181N/A<
CODE>M</
CODE> is present. The interpretation is as follows:
<
DD>the second and all subsequent parts
<
DD>the penultimate and all preceding parts
<
DT><
CODE>1+</
CODE> and <
CODE>-1+</
CODE>
<
DD>the same as <
CODE>0</
CODE>
If <
CODE>N</
CODE> or <
CODE>M</
CODE> is greater than the number of
parts available a single underscore is interpolated.
For simple name-based virtual hosts you might use the following
directives in your server configuration file:
will be satisfied by the file
For a very large number of virtual hosts it is a good idea to arrange
the files to reduce the size of the <
CODE>vhosts</
CODE> directory. To
do this you might use the following in your configuration file:
will be satisfied by the file
A more even spread of files can be achieved by hashing from the end of
The example request would come from
Alternatively you might use:
The example request would come from
For IP-based virtual hosting you might use the following in your
would be satisfied by the file
would be satisfied by executing the program
<
CODE>%V</
CODE> and <
CODE>%A</
CODE> are useful in conjunction with
<
LI><
A HREF="#virtualdocumentroot">VirtualDocumentRoot</
A>
<
LI><
A HREF="#virtualdocumentrootip">VirtualDocumentRootIP</
A>
<
LI><
A HREF="#virtualscriptalias">VirtualScriptAlias</
A>
<
LI><
A HREF="#virtualscriptaliasip">VirtualScriptAliasIP</
A>
<
H2><
A NAME="virtualdocumentroot">VirtualDocumentRoot directive</
A></
H2>
><
STRONG>Syntax:</
STRONG></
A> VirtualDocumentRoot <
EM>interpolated-directory</
EM><
BR>
><
STRONG>Default:</
STRONG></
A> None<
BR>
><
STRONG>Context:</
STRONG></
A> server config, virtual host<
BR>
><
STRONG>Status:</
STRONG></
A> Extension<
BR>
><
STRONG>Module:</
STRONG></
A> mod_vhost_alias<
BR>
><
STRONG>Compatibility:</
STRONG></
A> VirtualDocumentRoot is only available in 1.3.7 and later.</
P>
The <
CODE>VirtualDocumentRoot</
CODE> directive allows you to determine
where Apache will find your documents based on the value of the server
name. The result of expanding <
EM>interpolated-directory</
EM> is used
as the root of the document tree in a similar manner to the
<
A HREF="core.html#documentroot"><
CODE>DocumentRoot</
CODE></
A>
directive's argument. If <
EM>interpolated-directory</
EM> is
<
CODE>none</
CODE> then <
CODE>VirtaulDocumentRoot</
CODE> is turned off.
This directive cannot be used in the same context as
<
A HREF="#virtualdocumentrootip"><
CODE>VirtualDocumentRootIP</
CODE></
A>.
<
H2><
A NAME="virtualdocumentrootip">VirtualDocumentRootIP directive</
A></
H2>
><
STRONG>Syntax:</
STRONG></
A> VirtualDocumentRootIP <
EM>interpolated-directory</
EM><
BR>
><
STRONG>Default:</
STRONG></
A> None<
BR>
><
STRONG>Context:</
STRONG></
A> server config, virtual host<
BR>
><
STRONG>Status:</
STRONG></
A> Extension<
BR>
><
STRONG>Module:</
STRONG></
A> mod_vhost_alias<
BR>
><
STRONG>Compatibility:</
STRONG></
A> VirtualDocumentRootIP is only available in 1.3.7 and later.</
P>
The <
CODE>VirtualDocumentRootIP</
CODE> directive is like the
<
A HREF="#virtualdocumentroot"><
CODE>VirtualDocumentRoot</
CODE></
A> directive,
except that it uses the IP address of the server end of the connection
instead of the server name.
<
H2><
A NAME="virtualscriptalias">VirtualScriptAlias directive</
A></
H2>
><
STRONG>Syntax:</
STRONG></
A> VirtualScriptAlias <
EM>interpolated-directory</
EM><
BR>
><
STRONG>Default:</
STRONG></
A> None<
BR>
><
STRONG>Context:</
STRONG></
A> server config, virtual host<
BR>
><
STRONG>Status:</
STRONG></
A> Extension<
BR>
><
STRONG>Module:</
STRONG></
A> mod_vhost_alias<
BR>
><
STRONG>Compatibility:</
STRONG></
A> VirtualScriptAlias is only available in 1.3.7 and later.</
P>
The <
CODE>VirtualScriptAlias</
CODE> directive allows you to determine
where Apache will find CGI scripts in a similar manner to
<
A HREF="#virtualdocumentroot"><
CODE>VirtualDocumentRoot</
CODE></
A>
does for other documents. It matches requests for URIs starting
<
CODE>/cgi-bin/</
CODE>, much like
<
CODE><
A HREF="mod_alias.html#scriptalias">ScriptAlias</
A> /cgi-bin/</
CODE>
<
H2><
A NAME="virtualscriptaliasip">VirtualScriptAliasIP directive</
A></
H2>
><
STRONG>Syntax:</
STRONG></
A> VirtualScriptAliasIP <
EM>interpolated-directory</
EM><
BR>
><
STRONG>Default:</
STRONG></
A> None<
BR>
><
STRONG>Context:</
STRONG></
A> server config, virtual host<
BR>
><
STRONG>Status:</
STRONG></
A> Extension<
BR>
><
STRONG>Module:</
STRONG></
A> mod_vhost_alias<
BR>
><
STRONG>Compatibility:</
STRONG></
A> VirtualScriptAliasIP is only available in 1.3.7 and later.</
P>
The <
CODE>VirtualScriptAliasIP</
CODE> directive is like the
<
A HREF="#virtualscriptalias"><
CODE>VirtualScriptAlias</
CODE></
A> directive,
except that it uses the IP address of the server end of the connection
instead of the server name.
Apache HTTP Server Version 1.3