mod_vhost_alias.html revision 275e0e9c99eac4123651c4e86d93b1324da05e63
0N/A<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2051N/A<HTML>
0N/A<HEAD>
0N/A<TITLE>Apache module mod_vhost_alias</TITLE>
0N/A</HEAD>
0N/A
0N/A<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
0N/A<BODY
0N/A BGCOLOR="#FFFFFF"
0N/A TEXT="#000000"
0N/A LINK="#0000FF"
0N/A VLINK="#000080"
0N/A ALINK="#FF0000"
0N/A>
0N/A<DIV ALIGN="CENTER">
0N/A <IMG SRC="/images/sub.gif" ALT="[APACHE DOCUMENTATION]">
0N/A <H3>
0N/A Apache HTTP Server Version 1.3
1472N/A </H3>
1472N/A</DIV>
1472N/A
0N/A<H1 ALIGN="CENTER">Module mod_vhost_alias</H1>
0N/A
0N/A<P>
1879N/AThis module is contained in the <CODE>mod_vhost_alias.c</CODE> file
1879N/Aand is not compiled in by default. It should be mentioned near the
1879N/Astart of the <CODE>Configuration</CODE> file so that it doesn't
1879N/Aoverride the behaviour of other modules that do filename translation,
1879N/Ae.g. <A HREF="mod_userdir.html"><CODE>mod_userdir</CODE></A> and
1879N/A<A HREF="mod_alias.html"><CODE>mod_alias</CODE></A>. It provides
0N/Asupport for <A HREF="/vhost/mass.html">dynamically configured mass
0N/Avirtual hosting</A>.
1504N/A</P>
1504N/A
1504N/A<H2>Directory Name Interpolation</H2>
1504N/A
1504N/A<P>
0N/AAll the directives in this module interpolate a string into a
0N/Apathname. The interpolated string (henceforth called the "name") may
0N/Abe either the server name (see the
0N/A<A HREF="core.html#usecanonicalname"><CODE>UseCanonicalName</CODE></A>
0N/Adirective for details on how this is determined) or the IP address of
0N/Athe virtual host on the server in dotted-quad format. The
0N/Ainterpolation is controlled by specifiers inspired by
0N/A<CODE>printf</CODE> which have a number of formats:
1504N/A<DL>
1504N/A <DT><CODE>%%</CODE>
0N/A <DD>insert a <CODE>%</CODE>
0N/A <DT><CODE>%p</CODE>
1504N/A <DD>insert the port number of the virtual host
0N/A <DT><CODE>%N.M</CODE>
0N/A <DD>insert (part of) the name
0N/A</DL>
0N/A</P>
0N/A
0N/A<P>
0N/A<CODE>N</CODE> and <CODE>M</CODE> are used to specify substrings of
0N/Athe name. <CODE>N</CODE> selects from the dot-separated components of
0N/Athe name, and <CODE>M</CODE> selects characters within whatever
0N/A<CODE>N</CODE> has selected. <CODE>M</CODE> is optional and defaults
0N/Ato zero if it isn't present; the dot must be present if and only if
0N/A<CODE>M</CODE> is present. The interpretation is as follows:
0N/A<DL>
0N/A <DT><CODE>0</CODE>
0N/A <DD>the whole name
0N/A <DT><CODE>1</CODE>
0N/A <DD>the first part
0N/A <DT><CODE>2</CODE>
0N/A <DD>the second part
0N/A <DT><CODE>-1</CODE>
0N/A <DD>the last part
0N/A <DT><CODE>-2</CODE>
0N/A <DD>the penultimate part
0N/A <DT><CODE>2+</CODE>
0N/A <DD>the second and all subsequent parts
0N/A <DT><CODE>-2+</CODE>
0N/A <DD>the penultimate and all preceding parts
0N/A <DT><CODE>1+</CODE> and <CODE>-1+</CODE>
0N/A <DD>the same as <CODE>0</CODE>
0N/A</DL>
0N/AIf <CODE>N</CODE> or <CODE>M</CODE> is greater than the number of
0N/Aparts available a single underscore is interpolated.
0N/A</P>
0N/A
0N/A<H3>Examples</H3>
0N/A
0N/A<P>
0N/AFor simple name-based virtual hosts you might use the following
0N/Adirectives in your server configuration file:
0N/A<PRE>
0N/A UseCanonicalName Off
0N/A VirtualDocumentRoot /usr/local/apache/vhosts/%0
0N/A</PRE>
0N/AA request for <CODE>http://www.example.com/directory/file.html</CODE>
0N/Awill be satisfied by the file
0N/A<CODE>/usr/local/apache/vhosts/www.example.com/directory/file.html</CODE>.
0N/A</P>
0N/A
0N/A<P>
0N/AFor a very large number of virtual hosts it is a good idea to arrange
0N/Athe files to reduce the size of the <CODE>vhosts</CODE> directory. To
0N/Ado this you might use the following in your configuration file:
0N/A<PRE>
0N/A UseCanonicalName Off
0N/A VirtualDocumentRoot /usr/local/apache/vhosts/%3+/%2.1/%2.2/%2.3/%2
0N/A</PRE>
0N/AA request for <CODE>http://www.example.isp.com/directory/file.html</CODE>
0N/Awill be satisfied by the file
0N/A<CODE>/usr/local/apache/isp.com/e/x/a/example/directory/file.html</CODE>.
0N/AA more even spread of files can be acheived by hashing from the end of
0N/Athe name, for example:
0N/A<PRE>
0N/A VirtualDocumentRoot /u/%3+/%2.-1/%2.-2/%2.-3/%2
0N/A</PRE>
0N/AThe example request would come from
0N/A<CODE>/usr/local/apache/vhosts/isp.com/e/l/p/example/directory/file.html</CODE>.
0N/AAlternatively you might use:
0N/A<PRE>
0N/A VirtualDocumentRoot /usr/local/apache/vhosts/%3+/%2.1/%2.2/%2.3/%2.4+
0N/A</PRE>
0N/AThe example request would come from
0N/A<CODE>/usr/local/apache/vhosts/isp.com/e/x/a/mple/directory/file.html</CODE>.
0N/A</P>
0N/A
0N/A<P>
0N/AFor IP-based virtual hosting you might use the following in your
0N/Aconfiguration file:
0N/A<PRE>
0N/A UseCanonicalName DNS
0N/A VirtualDocumentRootIP /usr/local/apache/vhost/%1/%2/%3/%4/docs
0N/A VirtualScriptAliasIP /usr/local/apache/vhost/%1/%2/%3/%4/cgi-bin
0N/A</PRE>
0N/AA request for <CODE>http://www.example.isp.com/directory/file.html</CODE>
0N/Awould be satisfied by the file
0N/A<CODE>/usr/local/apache/10/20/30/40/docs/directory/file.html</CODE> if
0N/Athe IP address of <CODE>www.example.com</CODE> were 10.20.30.40.
0N/AA request for <CODE>http://www.example.isp.com/cgi-bin/script.pl</CODE>
0N/Awould be satisfied by executing the program
0N/A<CODE>/usr/local/apache/10/20/30/40/cgi-bin/script.pl</CODE>.
0N/A</P>
0N/A
0N/A<P>
0N/AThe <A HREF="mod_log_config.html#formats">LogFormat directives</A>
0N/A<CODE>%V</CODE> and <CODE>%A</CODE> are useful in conjunction with
0N/Athis module.
0N/A</P>
0N/A
0N/A<HR>
0N/A
0N/A<H2>Directives</H2>
0N/A<UL>
0N/A <LI><A HREF="#VirtualDocumentRoot">VirtualDocumentRoot</A>
0N/A <LI><A HREF="#VirtualDocumentRootIP">VirtualDocumentRootIP</A>
0N/A <LI><A HREF="#VirtualScriptAlias">VirtualScriptAlias</A>
0N/A <LI><A HREF="#VirtualScriptAliasIP">VirtualScriptAliasIP</A>
0N/A</UL>
0N/A<HR>
0N/A
0N/A<H2><A NAME="VirtualDocumentRoot">VirtualDocumentRoot directive</A></H2>
0N/A<P>
0N/A<A
0N/A HREF="directive-dict.html#Syntax"
0N/A REL="Help"
0N/A><STRONG>Syntax:</STRONG></A> VirtualDocumentRoot <EM>interpolated-directory</EM><BR>
0N/A<A
0N/A HREF="directive-dict.html#Default"
0N/A REL="Help"
0N/A><STRONG>Default:</STRONG></A> None<BR>
0N/A<A
0N/A HREF="directive-dict.html#Context"
0N/A REL="Help"
0N/A><STRONG>Context:</STRONG></A> server config, virtual host<BR>
0N/A<A
0N/A HREF="directive-dict.html#Status"
0N/A REL="Help"
0N/A><STRONG>Status:</STRONG></A> Extension<BR>
0N/A<A
0N/A HREF="directive-dict.html#Module"
0N/A REL="Help"
0N/A><STRONG>Module:</STRONG></A> mod_vhost_alias<BR>
0N/A<A
0N/A HREF="directive-dict.html#Compatibility"
0N/A REL="Help"
0N/A><STRONG>Compatibility:</STRONG></A> VirtualDocumentRoot is only available in 1.3.5 and later.</P>
0N/A<P>
0N/AThe <CODE>VirtualDocumentRoot</CODE> directive allows you to determine
0N/Awhere Apache will find your documents based on the value of the server
0N/Aname. The result of expanding <EM>interpolated-directory</EM> is used
0N/Aas the root of the document tree in a similar manner to the
0N/A<A HREF="core.html#documentroot"><CODE>DocumentRoot</CODE></A>
0N/Adirective's argument. If <EM>interpolated-directory</EM> is
0N/A<CODE>none</CODE> then <CODE>VirtaulDocumentRoot</CODE> is turned off.
0N/AThis directive cannot be used in the same context as
0N/A<A HREF="#VirtualDocumentRootIP"><CODE>VirtualDocumentRootIP</CODE></A>.
0N/A</P>
0N/A<HR>
0N/A
0N/A<H2><A NAME="VirtualDocumentRootIP">VirtualDocumentRootIP directive</A></H2>
0N/A<P>
0N/A<A
0N/A HREF="directive-dict.html#Syntax"
0N/A REL="Help"
0N/A><STRONG>Syntax:</STRONG></A> VirtualDocumentRootIP <EM>interpolated-directory</EM><BR>
0N/A<A
0N/A HREF="directive-dict.html#Default"
0N/A REL="Help"
0N/A><STRONG>Default:</STRONG></A> None<BR>
0N/A<A
0N/A HREF="directive-dict.html#Context"
0N/A REL="Help"
0N/A><STRONG>Context:</STRONG></A> server config, virtual host<BR>
2199N/A<A
0N/A HREF="directive-dict.html#Status"
0N/A REL="Help"
0N/A><STRONG>Status:</STRONG></A> Extension<BR>
0N/A<A
0N/A HREF="directive-dict.html#Module"
0N/A REL="Help"
0N/A><STRONG>Module:</STRONG></A> mod_vhost_alias<BR>
0N/A<A
0N/A HREF="directive-dict.html#Compatibility"
0N/A REL="Help"
0N/A><STRONG>Compatibility:</STRONG></A> VirtualDocumentRootIP is only available in 1.3.5 and later.</P>
0N/A<P>
0N/AThe <CODE>VirtualDocumentRootIP</CODE> directive is like the
0N/A<A HREF="#VirtualDocumentRoot"><CODE>VirtualDocumentRoot</CODE></A> directive,
0N/Aexcept that it uses the IP address of the server end of the connection
0N/Ainstead of the server name.
0N/A</P>
0N/A<HR>
0N/A
1295N/A<H2><A NAME="VirtualScriptAlias">VirtualScriptAlias directive</A></H2>
1295N/A<P>
1295N/A<A
1295N/A HREF="directive-dict.html#Syntax"
1295N/A REL="Help"
1295N/A><STRONG>Syntax:</STRONG></A> VirtualScriptAlias <EM>interpolated-directory</EM><BR>
1295N/A<A
1295N/A HREF="directive-dict.html#Default"
1295N/A REL="Help"
0N/A><STRONG>Default:</STRONG></A> None<BR>
0N/A<A
0N/A HREF="directive-dict.html#Context"
0N/A REL="Help"
0N/A><STRONG>Context:</STRONG></A> server config, virtual host<BR>
0N/A<A
0N/A HREF="directive-dict.html#Status"
0N/A REL="Help"
0N/A><STRONG>Status:</STRONG></A> Extension<BR>
0N/A<A
0N/A HREF="directive-dict.html#Module"
0N/A REL="Help"
0N/A><STRONG>Module:</STRONG></A> mod_vhost_alias<BR>
0N/A<A
0N/A HREF="directive-dict.html#Compatibility"
0N/A REL="Help"
0N/A><STRONG>Compatibility:</STRONG></A> VirtualScriptAlias is only available in 1.3.5 and later.</P>
0N/A<P>
0N/AThe <CODE>VirtualScriptAlias</CODE> directive allows you to determine
0N/Awhere Apache will find CGI scripts in a similar manner to
0N/A<A HREF="#VirtualDocumentRoot"><CODE>VirtualDocumentRoot</CODE></A>
0N/Adoes for other documents. It matches requests for URIs starting
1739N/A<CODE>/cgi-bin/</CODE>, much like
0N/A<CODE><A HREF="mod_alias.html#scriptalias">ScriptAlias</A> /cgi-bin/</CODE>
0N/Awould.
0N/A</P>
0N/A<HR>
0N/A
0N/A<H2><A NAME="VirtualScriptAlias">VirtualScriptAliasIP directive</A></H2>
0N/A<P>
0N/A<A
0N/A HREF="directive-dict.html#Syntax"
0N/A REL="Help"
0N/A><STRONG>Syntax:</STRONG></A> VirtualScriptAliasIP <EM>interpolated-directory</EM><BR>
0N/A<A
0N/A HREF="directive-dict.html#Default"
0N/A REL="Help"
0N/A><STRONG>Default:</STRONG></A> None<BR>
0N/A<A
0N/A HREF="directive-dict.html#Context"
0N/A REL="Help"
0N/A><STRONG>Context:</STRONG></A> server config, virtual host<BR>
0N/A<A
0N/A HREF="directive-dict.html#Status"
0N/A REL="Help"
0N/A><STRONG>Status:</STRONG></A> Extension<BR>
0N/A<A
0N/A HREF="directive-dict.html#Module"
0N/A REL="Help"
0N/A><STRONG>Module:</STRONG></A> mod_vhost_alias<BR>
0N/A<A
0N/A HREF="directive-dict.html#Compatibility"
0N/A REL="Help"
0N/A><STRONG>Compatibility:</STRONG></A> VirtualScriptAliasIP is only available in 1.3.5 and later.</P>
0N/A<P>
0N/AThe <CODE>VirtualScriptAliasIP</CODE> directibe is like the
0N/A<A HREF="#VirtualScriptAlias"><CODE>VirtualScriptAlias</CODE></A> directive,
0N/Aexcept that it uses the IP address of the server end of the connection
0N/Ainstead of the server name.
0N/A</P>
0N/A<HR>
0N/A
0N/A<H3 ALIGN="CENTER">
0N/A Apache HTTP Server Version 1.3
0N/A</H3>
0N/A
0N/A<A HREF="./"><IMG SRC="/images/index.gif" ALT="Index"></A>
0N/A<A HREF="../"><IMG SRC="/images/home.gif" ALT="Home"></A>
0N/A
0N/A</BODY>
0N/A</HTML>
0N/A