mod_alias.html revision b0b7b0b13efb14899243af0ead86cc69d0b52817
2685N/A<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
100N/A<HTML>
100N/A<HEAD>
100N/A<TITLE>Apache module mod_alias</TITLE>
100N/A</HEAD>
100N/A
100N/A<BODY>
100N/A<!--#include virtual="header.html" -->
100N/A
100N/A<H1>Module mod_alias</h1>
100N/A
100N/AThis module is contained in the <code>mod_alias.c</code> file, and
100N/Ais compiled in by default. It provides for mapping different parts of the
100N/Ahost filesystem in the the document tree, and for URL redirection.
100N/A
100N/A
100N/A<menu>
1472N/A<li><A HREF="#alias">Alias</A>
1472N/A<li><A HREF="#redirect">Redirect</A>
1472N/A<li><A HREF="#redirecttemp">RedirectTemp</A>
100N/A<li><A HREF="#redirectperm">RedirectPermanent</A>
100N/A<li><A HREF="#scriptalias">ScriptAlias</A>
100N/A</menu>
100N/A<hr>
100N/A
100N/A
100N/A<A name="alias"><h2>Alias</h2></A>
100N/A<!--%plaintext &lt;?INDEX {\tt Alias} directive&gt; -->
100N/A<strong>Syntax:</strong> Alias <em>url-path directory-filename</em><br>
100N/A<Strong>Context:</strong> server config, virtual host<br>
100N/A<strong>Status:</strong> Base<br>
100N/A<strong>Module:</strong> mod_alias<br>
100N/A
100N/AThe Alias directive allows documents to be stored in the local filesystem
720N/Aother than under the <A HREF="core.html#documentroot">DocumentRoot</A>.
720N/AURLs with a (%-decoded) path beginning with <em>url-path</em> will be
720N/Amapped to local files beginning with <em>directory-filename</em>.
720N/AExample:
720N/A<blockquote><code>Alias /image /ftp/pub/image</code></blockquote>
100N/AA request for http://myserver/image/foo.gif would cause the server to
720N/Areturn the file /ftp/pub/image/foo.gif.<p>
720N/ASee also <A HREF="#scriptalias">ScriptAlias</A>.<p><hr>
720N/A
720N/A<A name="redirect"><h2>Redirect</h2></A>
720N/A<!--%plaintext &lt;?INDEX {\tt Redirect} directive&gt; -->
720N/A<strong>Syntax:</strong> Redirect [ <em>status</em> ] <em>url-path url</em><br>
720N/A<Strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
720N/A<strong>Status:</strong> Base<br>
720N/A<strong>Module:</strong> mod_alias<br>
100N/A<strong>Compatibility:</strong> The directory and .htaccess context's
720N/Aare only available in versions 1.1 and later. The <em>status</em> argument is only available in Apache 1.2 or later.<p>
100N/A
720N/AThe Redirect directive maps an old URL into a new one. The new URL is returned
720N/Ato the client which attempts to fetch it again with the new address.
720N/A<em>Url-path</em> a (%-decoded) path; any requests for documents beginning with
720N/Athis path will be returned a redirect error to a new (%-encoded) url
720N/Abeginning with <em>url</em>. Example:
720N/A<blockquote><code>Redirect /service
720N/Ahttp://foo2.bar.com/service</code></blockquote>
720N/AIf the client requests http://myserver/service/foo.txt, it will be told to
720N/Aaccess http://foo2.bar.com/service/foo.txt instead.<p>
720N/A
720N/ANote: Redirect directives take precedence over Alias and ScriptAlias
720N/Adirectives, irrespective of their ordering in the configuration file. Also,
720N/A<em>Url-path</em> must be an absolute path, not a relative path, even when used with
720N/A.htaccess files or inside of &lt;Directory&gt; sections.<p>
720N/A
720N/AIf no <em>status</em> argument is given, the redirect will be
720N/A"temporary" (HTTP status 302). This indicates to the client that the
100N/Aresources is has moved temporarily. The <em>status</em>
720N/Aargument can be used to return other HTTP status codes:
100N/A<dl>
720N/A<dt>permanent<dd>Returns a permanent redirect status (301) indicating that
100N/Athe resource has moved permanently.
100N/A<dt>temp<dd>Returns a temporary redirect status (302). This is the
100N/Adefault.
720N/A<dt>seeother<dd>Returns a "See Other" status (303) indicating that
2619N/Athe resource has been replaced.
2619N/A<dt>gone<dd>Returns a "Gone" status (410) indicating that the resource
2619N/Ahas been permanently removed. When this status is used the <em>url</em>
2619N/Aargument should be omitted.
2619N/A</dl>
2619N/A
2619N/AOther status codes can be returned by giving the numeric status code
2619N/Aas the value of <em>status</em>. If the status is between 300 and 399,
2619N/Athe <em>url</em> argument must be present, otherwise it must be
2619N/Aomitted. Note that the status must be known to the Apache code (see
100N/Athe function <code>send_error_response</code> in http_protocol.c).
100N/A
720N/A<A name="redirecttemp"><h2>RedirectTemp</h2></A>
720N/A<!--%plaintext &lt;?INDEX {\tt Redirect} directive&gt; -->
100N/A<strong>Syntax:</strong> RedirectTemp <em>url-path url</em><br>
100N/A<Strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
100N/A<strong>Status:</strong> Base<br>
100N/A<strong>Module:</strong> mod_alias<br>
100N/A<strong>Compatibility:</strong> This directive is only available in 1.2<P>
100N/A
This directive makes the client know that the Redirect is only
temporary. (Status 302). Exactly equivalent to <code>Redirect temporary </code><P>
<A name="redirectperm"><h2>RedirectPermanent</h2></A>
<!--%plaintext &lt;?INDEX {\tt Redirect} directive&gt; -->
<strong>Syntax:</strong> RedirectPermanent <em>url-path url</em><br>
<Strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
<strong>Status:</strong> Base<br>
<strong>Module:</strong> mod_alias<br>
<strong>Compatibility:</strong> This directive is only available in 1.2<P>
This directive makes the client know that the Redirect is permanent.
(Status 301). Exactly equivalent to <code>Redirect permanent</code><P>
<hr>
<A name="scriptalias"><h2>ScriptAlias</h2></A>
<!--%plaintext &lt;?INDEX {\tt ScriptAlias} directive&gt; -->
<strong>Syntax:</strong> ScriptAlias <em>url-path directory-filename</em><br>
<Strong>Context:</strong> server config, virtual host<br>
<strong>Status:</strong> Base<br>
<strong>Module:</strong> mod_alias<br>
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>.
Example:
<blockquote><code>ScriptAlias /cgi-bin/ /web/cgi-bin/</code></blockquote>
A request for http://myserver/cgi-bin/foo would cause the server to
run the script /web/cgi-bin/foo.<p>
<!--#include virtual="footer.html" -->
</BODY>
</HTML>