mod_alias.html revision 8427d9c632f123b178313843b8f1c67655807311
45632c3574ce843b9e85b9f73efe75b7b809f789slive<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<HTML>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<HEAD>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<TITLE>Apache module mod_alias</TITLE>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd</HEAD>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
6df89e6e4adeb986b41b7ec6b7593a887e031ce7nd<BODY
6df89e6e4adeb986b41b7ec6b7593a887e031ce7nd BGCOLOR="#FFFFFF"
7add1372edb1ee95a2c4d1314df4c7567bda7c62jim TEXT="#000000"
7add1372edb1ee95a2c4d1314df4c7567bda7c62jim LINK="#0000FF"
7add1372edb1ee95a2c4d1314df4c7567bda7c62jim VLINK="#000080"
7add1372edb1ee95a2c4d1314df4c7567bda7c62jim ALINK="#FF0000"
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<!--#include virtual="header.html" -->
7add1372edb1ee95a2c4d1314df4c7567bda7c62jim
52fff662005b1866a3ff09bb6c902800c5cc6dedjerenkrantz<H1 ALIGN="CENTER">Module mod_alias</H1>
7add1372edb1ee95a2c4d1314df4c7567bda7c62jim<P>
7add1372edb1ee95a2c4d1314df4c7567bda7c62jimThis module is contained in the <CODE>mod_alias.c</CODE> file, and
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26ndis compiled in by default. It provides for mapping different parts of the
4b5981e276e93df97c34e4da05ca5cf8bbd937dandhost filesystem in the the document tree, and for URL redirection.
6df89e6e4adeb986b41b7ec6b7593a887e031ce7nd</P>
6df89e6e4adeb986b41b7ec6b7593a887e031ce7nd
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd<H2>Directives</H2>
ed1d958582984a7c54a6ca859e15939a414fa733nd<UL>
ed1d958582984a7c54a6ca859e15939a414fa733nd<LI><A HREF="#alias">Alias</A>
7add1372edb1ee95a2c4d1314df4c7567bda7c62jim<LI><A HREF="#aliasmatch">AliasMatch</A>
7add1372edb1ee95a2c4d1314df4c7567bda7c62jim<LI><A HREF="#redirect">Redirect</A>
7add1372edb1ee95a2c4d1314df4c7567bda7c62jim<LI><A HREF="#redirectmatch">RedirectMatch</A>
7f5b59ccc63c0c0e3e678a168f09ee6a2f51f9d0nd<LI><A HREF="#redirecttemp">RedirectTemp</A>
7f5b59ccc63c0c0e3e678a168f09ee6a2f51f9d0nd<LI><A HREF="#redirectperm">RedirectPermanent</A>
63f06dce77bb2d9b1c5aa5deeb47a1069987fd1end<LI><A HREF="#scriptalias">ScriptAlias</A>
63f06dce77bb2d9b1c5aa5deeb47a1069987fd1end<LI><A HREF="#scriptaliasmatch">ScriptAliasMatch</A>
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd</UL>
52fff662005b1866a3ff09bb6c902800c5cc6dedjerenkrantz<HR>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd
a29610af88e278144045bfa1bc63b4a1a4b5ff14trawick
52fff662005b1866a3ff09bb6c902800c5cc6dedjerenkrantz<H2><A name="alias">Alias directive</A></H2>
35b1112eadc3479a2d81ea1b836aa87f21505ee9jerenkrantz<P>
52fff662005b1866a3ff09bb6c902800c5cc6dedjerenkrantz<!--%plaintext &lt;?INDEX {\tt Alias} directive&gt; -->
a12dd6260a66f51e25119982390def72e2db4be5nd<A
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd HREF="directive-dict.html#Syntax"
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd REL="Help"
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd><STRONG>Syntax:</STRONG></A> Alias <EM>url-path directory-filename</EM><BR>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<A
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd HREF="directive-dict.html#Context"
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd REL="Help"
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd><STRONG>Context:</STRONG></A> server config, virtual host<BR>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<A
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd HREF="directive-dict.html#Status"
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd REL="Help"
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd><STRONG>Status:</STRONG></A> Base<BR>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<A
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd HREF="directive-dict.html#Module"
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd REL="Help"
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd><STRONG>Module:</STRONG></A> mod_alias
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd</P>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<P>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26ndThe Alias directive allows documents to be stored in the local filesystem
4af55bbfdbff2cae0cd3195876c93ea991523d1fcolmother than under the <A HREF="core.html#documentroot">DocumentRoot</A>.
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26ndURLs with a (%-decoded) path beginning with <EM>url-path</EM> will be
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26ndmapped to local files beginning with <EM>directory-filename</EM>.
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<P>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26ndExample:
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd</P>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<BLOCKQUOTE><CODE>Alias /image /ftp/pub/image</CODE></BLOCKQUOTE>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<P>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26ndA request for http://myserver/image/foo.gif would cause the server to
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26ndreturn the file /ftp/pub/image/foo.gif.
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd</P>
38819b9bf8b10d6db4842fb5a4ede7828b409819rbowen<P>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26ndNote that if you include a trailing / on the <EM>url-path</EM> then the
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26ndserver will require a trailing / in order to expand the alias. That is,
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26ndif you use <CODE>Alias /icons/ /usr/local/apache/icons/</CODE> then
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26ndthe url <CODE>/icons</CODE> will not be aliased.
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd</P>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<p>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26ndNote that you may need to specify additional
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<a href="core.html#directory"><code>&lt;Directory&gt;</code></a> sections
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26ndwhich cover the <i>destination</i> of aliases. Aliasing occurs
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26ndbefore <code>&lt;Directory&gt;</code> sections are checked, so only
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26ndthe destination of aliases are affected. (Note however
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<a href="core.html#location"><code>&lt;Location&gt;</code></a>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26ndsections are run through once before aliases are performed, so they
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26ndwill apply.)
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<P>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26ndSee also <A HREF="#scriptalias">ScriptAlias</A>.
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd</P>
c5ac4f57bfd156a62495b9c6a049f05bbcb69acarbowen<HR>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<H2><A name="aliasmatch">AliasMatch</A></H2>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<P>
e930328445e961ade1bd37ed7ca01c293b586400noodl<A
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd HREF="directive-dict.html#Syntax"
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd REL="Help"
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd><STRONG>Syntax:</STRONG></A> AliasMatch <EM>regex directory-filename</EM><BR>
ed1d958582984a7c54a6ca859e15939a414fa733nd<A
ed1d958582984a7c54a6ca859e15939a414fa733nd HREF="directive-dict.html#Context"
7add1372edb1ee95a2c4d1314df4c7567bda7c62jim REL="Help"
7add1372edb1ee95a2c4d1314df4c7567bda7c62jim><STRONG>Context:</STRONG></A> server config, virtual host<BR>
7add1372edb1ee95a2c4d1314df4c7567bda7c62jim<A
7f5b59ccc63c0c0e3e678a168f09ee6a2f51f9d0nd HREF="directive-dict.html#Status"
7f5b59ccc63c0c0e3e678a168f09ee6a2f51f9d0nd REL="Help"
63f06dce77bb2d9b1c5aa5deeb47a1069987fd1end><STRONG>Status:</STRONG></A> Base<BR>
63f06dce77bb2d9b1c5aa5deeb47a1069987fd1end<A
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd HREF="directive-dict.html#Module"
50039065d571fe01fd458a3f031c995a1fd53c22rbowen REL="Help"
7add1372edb1ee95a2c4d1314df4c7567bda7c62jim><STRONG>Module:</STRONG></A> mod_alias<BR>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<A
HREF="directive-dict.html#Compatibility"
REL="Help"
><STRONG>Compatibility:</STRONG></A> Available in Apache 1.3 and later
</P>
<P>This directive is equivalent to <A HREF="#alias">Alias</A>, but
makes use of standard regular expressions, instead of simple prefix
matching. The supplied regular expression is matched against the URL,
and if it matches, the server will substitute any parenthesized
matches into the given string and use it as a filename. For example,
to activate the <CODE>/icons</CODE> directory, one might use:
<PRE>
AliasMatch ^/icons(.*) /usr/local/apache/icons$1
</PRE>
</P>
<HR>
<H2><A name="redirect">Redirect directive</A></H2>
<P>
<!--%plaintext &lt;?INDEX {\tt Redirect} directive&gt; -->
<A
HREF="directive-dict.html#Syntax"
REL="Help"
><STRONG>Syntax:</STRONG></A> Redirect [ <EM>status</EM> ] <EM>url-path url</EM><BR>
<A
HREF="directive-dict.html#Context"
REL="Help"
><STRONG>Context:</STRONG></A> server config, virtual host, directory, .htaccess<BR>
<A
HREF="directive-dict.html#Status"
REL="Help"
><STRONG>Status:</STRONG></A> Base<BR>
<A
HREF="directive-dict.html#Module"
REL="Help"
><STRONG>Module:</STRONG></A> mod_alias<BR>
<A
HREF="directive-dict.html#Compatibility"
REL="Help"
><STRONG>Compatibility:</STRONG></A> The directory and .htaccess context's
are only available in versions 1.1 and later. The <EM>status</EM>
argument is only available in Apache 1.2 or later.
</P>
<P>
The Redirect directive maps an old URL into a new one. The new URL is returned
to the client which attempts to fetch it again with the new address.
<EM>Url-path</EM> a (%-decoded) path; any requests for documents beginning with
this path will be returned a redirect error to a new (%-encoded) url
beginning with <EM>url</EM>.
</P>
<P>
Example:
</P>
<BLOCKQUOTE><CODE>Redirect /service
http://foo2.bar.com/service</CODE></BLOCKQUOTE>
<P>
If the client requests http://myserver/service/foo.txt, it will be told to
access http://foo2.bar.com/service/foo.txt instead.
</P>
<P>
<STRONG>Note:</STRONG> Redirect directives take precedence over Alias
and ScriptAlias
directives, irrespective of their ordering in the configuration file. Also,
<EM>Url-path</EM> must be an absolute path, not a relative path, even
when used with .htaccess files or inside of &lt;Directory&gt; sections.
</P>
<P>
If no <EM>status</EM> argument is given, the redirect will be
&quot;temporary&quot; (HTTP status 302). This indicates to the client that the
resources is has moved temporarily. The <EM>status</EM>
argument can be used to return other HTTP status codes:
<P>
<DL>
<DT>permanent
<DD>Returns a permanent redirect status (301) indicating that
the resource has moved permanently.
<DT>temp
<DD>Returns a temporary redirect status (302). This is the
default.
<DT>seeother
<DD>Returns a "See Other" status (303) indicating that
the resource has been replaced.
<DT>gone
<DD>Returns a "Gone" status (410) indicating that the resource
has been permanently removed. When this status is used the <EM>url</EM>
argument should be omitted.
</DL>
<P>
Other status codes can be returned by giving the numeric status code
as the value of <EM>status</EM>. If the status is between 300 and 399,
the <EM>url</EM> argument must be present, otherwise it must be
omitted. Note that the status must be known to the Apache code (see
the function <CODE>send_error_response</CODE> in http_protocol.c).
</P>
<HR>
<H2><A name="redirectmatch">RedirectMatch</A></H2>
<P>
<A
HREF="directive-dict.html#Syntax"
REL="Help"
><STRONG>Syntax:</STRONG></A> RedirectMatch [<EM>status</EM> <EM>regex url</EM><BR>
<A
HREF="directive-dict.html#Context"
REL="Help"
><STRONG>Context:</STRONG></A> server config, virtual host<BR>
<A
HREF="directive-dict.html#Status"
REL="Help"
><STRONG>Status:</STRONG></A> Base<BR>
<A
HREF="directive-dict.html#Module"
REL="Help"
><STRONG>Module:</STRONG></A> mod_alias<BR>
<A
HREF="directive-dict.html#Compatibility"
REL="Help"
><STRONG>Compatibility:</STRONG></A> Available in Apache 1.3 and later
</P>
<P>This directive is equivalent to <A HREF="#alias">Redirect</A>, but
makes use of standard regular expressions, instead of simple prefix
matching. The supplied regular expression is matched against the URL,
and if it matches, the server will substitute any parenthesized
matches into the given string and use it as a filename. For example,
to redirect all GIF files to like-named JPEG files on another server,
one might use:
<PRE>
RedirectMatch (.*)\.gif$ http://www.anotherserver.com$1.jpg
</PRE>
</P>
<HR>
<H2><A name="redirecttemp">RedirectTemp directive</A></H2>
<P>
<!--%plaintext &lt;?INDEX {\tt Redirect} directive&gt; -->
<A
HREF="directive-dict.html#Syntax"
REL="Help"
><STRONG>Syntax:</STRONG></A> RedirectTemp <EM>url-path url</EM><BR>
<A
HREF="directive-dict.html#Context"
REL="Help"
><STRONG>Context:</STRONG></A> server config, virtual host, directory, .htaccess<BR>
<A
HREF="directive-dict.html#Status"
REL="Help"
><STRONG>Status:</STRONG></A> Base<BR>
<A
HREF="directive-dict.html#Module"
REL="Help"
><STRONG>Module:</STRONG></A> mod_alias<BR>
<A
HREF="directive-dict.html#Compatibility"
REL="Help"
><STRONG>Compatibility:</STRONG></A> This directive is only available in 1.2
</P>
<P>
This directive makes the client know that the Redirect is only
temporary (status 302). Exactly equivalent to <CODE>Redirect
temporary</CODE>.
</P>
<HR>
<H2><A name="redirectperm">RedirectPermanent directive</A></H2>
<P>
<!--%plaintext &lt;?INDEX {\tt Redirect} directive&gt; -->
<A
HREF="directive-dict.html#Syntax"
REL="Help"
><STRONG>Syntax:</STRONG></A> RedirectPermanent <EM>url-path url</EM><BR>
<A
HREF="directive-dict.html#Context"
REL="Help"
><STRONG>Context:</STRONG></A> server config, virtual host, directory, .htaccess<BR>
<A
HREF="directive-dict.html#Status"
REL="Help"
><STRONG>Status:</STRONG></A> Base<BR>
<A
HREF="directive-dict.html#Module"
REL="Help"
><STRONG>Module:</STRONG></A> mod_alias<BR>
<A
HREF="directive-dict.html#Compatibility"
REL="Help"
><STRONG>Compatibility:</STRONG></A> This directive is only available in 1.2
</P>
<P>
This directive makes the client know that the Redirect is permanent
(status 301). Exactly equivalent to <CODE>Redirect permanent</CODE>.
</P>
<HR>
<H2><A name="scriptalias">ScriptAlias directive</A></H2>
<P>
<!--%plaintext &lt;?INDEX {\tt ScriptAlias} directive&gt; -->
<A
HREF="directive-dict.html#Syntax"
REL="Help"
><STRONG>Syntax:</STRONG></A> ScriptAlias <EM>url-path directory-filename</EM><BR>
<A
HREF="directive-dict.html#Context"
REL="Help"
><STRONG>Context:</STRONG></A> server config, virtual host<BR>
<A
HREF="directive-dict.html#Status"
REL="Help"
><STRONG>Status:</STRONG></A> Base<BR>
<A
HREF="directive-dict.html#Module"
REL="Help"
><STRONG>Module:</STRONG></A> mod_alias
</P>
<P>
The ScriptAlias directive has the same behavior as the
<A HREF="#alias">Alias</A> directive, except that in addition it
marks the target directory as containing CGI scripts.
URLs with a (%-decoded) path beginning with <EM>url-path</EM> will be
mapped to scripts beginning with <EM>directory-filename</EM>.
<P>
Example:
</P>
<BLOCKQUOTE><CODE>ScriptAlias /cgi-bin/ /web/cgi-bin/</CODE></BLOCKQUOTE>
<P>
A request for http://myserver/cgi-bin/foo would cause the server to
run the script /web/cgi-bin/foo.
</P>
<HR>
<H2><A name="scriptaliasmatch">ScriptAliasMatch</A></H2>
<P>
<A
HREF="directive-dict.html#Syntax"
REL="Help"
><STRONG>Syntax:</STRONG></A> ScriptAliasMatch <EM>regex directory-filename</EM><BR>
<A
HREF="directive-dict.html#Context"
REL="Help"
><STRONG>Context:</STRONG></A> server config, virtual host<BR>
<A
HREF="directive-dict.html#Status"
REL="Help"
><STRONG>Status:</STRONG></A> Base<BR>
<A
HREF="directive-dict.html#Module"
REL="Help"
><STRONG>Module:</STRONG></A> mod_alias<BR>
<A
HREF="directive-dict.html#Compatibility"
REL="Help"
><STRONG>Compatibility:</STRONG></A> Available in Apache 1.3 and later
</P>
<P>This directive is equivalent to <A HREF="#scriptalias">ScriptAlias</A>, but
makes use of standard regular expressions, instead of simple prefix
matching. The supplied regular expression is matched against the URL,
and if it matches, the server will substitute any parenthesized
matches into the given string and use it as a filename. For example,
to activate the standard <CODE>/cgi-bin</CODE>, one might use:
<PRE>
ScriptAliasMatch ^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
</PRE>
</P>
<!--#include virtual="footer.html" -->
</BODY>
</HTML>