mod_alias.html revision 2eaf662cbc81e823e8d9aeb8d54e69e63032493e
1516N/A<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3339N/A "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
1231N/A
1231N/A<html xmlns="http://www.w3.org/1999/xhtml">
3339N/A <head>
1231N/A <meta name="generator" content="HTML Tidy, see www.w3.org" />
1231N/A
2935N/A <title>Apache module mod_alias</title>
2935N/A </head>
2935N/A <!-- Background white, links blue (unvisited), navy (visited), red (active) -->
2935N/A
2935N/A <body bgcolor="#FFFFFF" text="#000000" link="#0000FF"
2935N/A vlink="#000080" alink="#FF0000">
2935N/A <!--#include virtual="header.html" -->
2935N/A
2935N/A <h1 align="CENTER">Module mod_alias</h1>
2935N/A
2935N/A <p>This module provides for mapping different parts of the host
2935N/A filesystem in the document tree, and for URL redirection.</p>
2935N/A
2935N/A <p><a href="module-dict.html#Status"
2935N/A rel="Help"><strong>Status:</strong></a> Base<br />
2935N/A <a href="module-dict.html#SourceFile"
2935N/A rel="Help"><strong>Source File:</strong></a> mod_alias.c<br />
2935N/A <a href="module-dict.html#ModuleIdentifier"
1231N/A rel="Help"><strong>Module Identifier:</strong></a>
1231N/A alias_module</p>
1231N/A
1231N/A <h2>Summary</h2>
3200N/A
3200N/A <p>The directives contained in this module allow for
1231N/A manipulation and control of URLs as requests arrive at the
2935N/A server. The <code>Alias</code> and <code>ScriptAlias</code>
2935N/A directives are used to map between URLs and filesystem paths.
2935N/A This allows for content which is not directly under the <a
2935N/A href="core.html#documentroot"><code>DocumentRoot</code></a> to
2935N/A be served as part of the web document tree. The
1231N/A <code>ScriptAlias</code> directive has the additional effect of
1231N/A marking the target directory as containing only CGI
1580N/A scripts.</p>
1580N/A
1580N/A <p>The <code>Redirect</code> directives are used to instruct
1580N/A clients to make a new request with a different URL. They are
1580N/A often used when a resource has moved to a new location.</p>
1580N/A
1580N/A <p>A more powerful and flexible set of directives for
1580N/A manipulating URLs is contained in the <a
1580N/A href="mod_rewrite.html"><code>mod_rewrite</code></a>
1580N/A module.</p>
1580N/A
1580N/A <h2>Directives</h2>
1580N/A
1580N/A <ul>
1580N/A <li><a href="#alias">Alias</a></li>
1580N/A
1580N/A <li><a href="#aliasmatch">AliasMatch</a></li>
3200N/A
3200N/A <li><a href="#redirect">Redirect</a></li>
3200N/A
3200N/A <li><a href="#redirectmatch">RedirectMatch</a></li>
3200N/A
3200N/A <li><a href="#redirecttemp">RedirectTemp</a></li>
3200N/A
3200N/A <li><a href="#redirectperm">RedirectPermanent</a></li>
3200N/A
1580N/A <li><a href="#scriptalias">ScriptAlias</a></li>
1580N/A
1580N/A <li><a href="#scriptaliasmatch">ScriptAliasMatch</a></li>
1580N/A </ul>
1580N/A <hr />
1580N/A
3200N/A <h2><a id="alias" name="alias">Alias directive</a></h2>
1580N/A
3200N/A <p><!--%plaintext &lt;?INDEX {\tt Alias} directive&gt; -->
1580N/A <a href="directive-dict.html#Syntax"
1580N/A rel="Help"><strong>Syntax:</strong></a> Alias <em>URL-path
1580N/A file-path</em>|<em>directory-path</em><br />
1580N/A <a href="directive-dict.html#Context"
1580N/A rel="Help"><strong>Context:</strong></a> server config, virtual
1580N/A host<br />
1580N/A <a href="directive-dict.html#Status"
1580N/A rel="Help"><strong>Status:</strong></a> Base<br />
1580N/A <a href="directive-dict.html#Module"
1580N/A rel="Help"><strong>Module:</strong></a> mod_alias</p>
3200N/A
1580N/A <p>The Alias directive allows documents to be stored in the
1580N/A local filesystem other than under the <a
3158N/A href="core.html#documentroot">DocumentRoot</a>. URLs with a
3200N/A (%-decoded) path beginning with <em>url-path</em> will be
1580N/A mapped to local files beginning with
2935N/A <em>directory-filename</em>.</p>
2935N/A
3352N/A <p>Example:</p>
3352N/A
3352N/A <blockquote>
3352N/A <code>Alias /image /ftp/pub/image</code>
3352N/A </blockquote>
3352N/A
3352N/A <p>A request for http://myserver/image/foo.gif would cause the
3352N/A server to return the file /ftp/pub/image/foo.gif.</p>
3352N/A
3352N/A <p>Note that if you include a trailing / on the
2935N/A <em>url-path</em> then the server will require a trailing / in
2935N/A order to expand the alias. That is, if you use <code>Alias
2935N/A /icons/ /usr/local/apache/icons/</code> then the url
2935N/A <code>/icons</code> will not be aliased.</p>
2935N/A
2935N/A <p>Note that you may need to specify additional <a
2935N/A href="core.html#directory"><code>&lt;Directory&gt;</code></a>
2935N/A sections which cover the <em>destination</em> of aliases.
1231N/A Aliasing occurs before <code>&lt;Directory&gt;</code> sections
1580N/A are checked, so only the destination of aliases are affected.
2381N/A (Note however <a
1231N/A href="core.html#location"><code>&lt;Location&gt;</code></a>
2236N/A sections are run through once before aliases are performed, so
2236N/A they will apply.)</p>
2236N/A
2236N/A <p>See also <a href="#scriptalias">ScriptAlias</a>.</p>
2236N/A <hr />
2236N/A
2236N/A <h2><a id="aliasmatch" name="aliasmatch">AliasMatch</a></h2>
1231N/A
1231N/A <p><a href="directive-dict.html#Syntax"
1231N/A rel="Help"><strong>Syntax:</strong></a> AliasMatch <em>regex
1231N/A file-path</em>|<em>directory-path</em><br />
1231N/A <a href="directive-dict.html#Context"
1231N/A rel="Help"><strong>Context:</strong></a> server config, virtual
1231N/A host<br />
1231N/A <a href="directive-dict.html#Status"
1231N/A rel="Help"><strong>Status:</strong></a> Base<br />
1231N/A <a href="directive-dict.html#Module"
1231N/A rel="Help"><strong>Module:</strong></a> mod_alias</p>
1231N/A
1231N/A <p>This directive is equivalent to <a href="#alias">Alias</a>,
2381N/A but makes use of standard regular expressions, instead of
1580N/A simple prefix matching. The supplied regular expression is
1231N/A matched against the URL-path, and if it matches, the server
2381N/A will substitute any parenthesized matches into the given string
1231N/A and use it as a filename. For example, to activate the
2236N/A <code>/icons</code> directory, one might use:</p>
2935N/A<pre>
2935N/A AliasMatch ^/icons(.*) /usr/local/apache/icons$1
2935N/A</pre>
2935N/A <br />
2935N/A <br />
2935N/A
2935N/A <hr />
2935N/A
2935N/A <h2><a id="redirect" name="redirect">Redirect
2935N/A directive</a></h2>
2935N/A
2935N/A <p><!--%plaintext &lt;?INDEX {\tt Redirect} directive&gt; -->
2935N/A <a href="directive-dict.html#Syntax"
2935N/A rel="Help"><strong>Syntax:</strong></a> Redirect
2935N/A [<em>status</em>] <em>URL-path URL</em><br />
2935N/A <a href="directive-dict.html#Context"
2935N/A rel="Help"><strong>Context:</strong></a> server config, virtual
2935N/A host, directory, .htaccess<br />
2935N/A <a href="directive-dict.html#Override"
2935N/A rel="Help"><strong>Override:</strong></a> FileInfo<br />
2935N/A <a href="directive-dict.html#Status"
2236N/A rel="Help"><strong>Status:</strong></a> Base<br />
1231N/A <a href="directive-dict.html#Module"
1231N/A rel="Help"><strong>Module:</strong></a> mod_alias</p>
1231N/A
1231N/A <p>The Redirect directive maps an old URL into a new one. The
1580N/A new URL is returned to the client which attempts to fetch it
1231N/A again with the new address. <em>URL-path</em> a (%-decoded)
1231N/A path; any requests for documents beginning with this path will
1231N/A be returned a redirect error to a new (%-encoded) URL beginning
1231N/A with <em>URL</em>.</p>
1231N/A
1580N/A <p>Example:</p>
1580N/A
1580N/A <blockquote>
1231N/A <code>Redirect /service http://foo2.bar.com/service</code>
1580N/A </blockquote>
1580N/A
1580N/A <p>If the client requests http://myserver/service/foo.txt, it
1580N/A will be told to access http://foo2.bar.com/service/foo.txt
1231N/A instead.</p>
1231N/A
1231N/A <p><strong>Note:</strong> Redirect directives take precedence
1231N/A over Alias and ScriptAlias directives, irrespective of their
1231N/A ordering in the configuration file. Also, <em>URL-path</em>
1231N/A must be an absolute path, not a relative path, even when used
1580N/A with .htaccess files or inside of &lt;Directory&gt;
1231N/A sections.</p>
1231N/A
1580N/A <p>If no <em>status</em> argument is given, the redirect will
1231N/A be "temporary" (HTTP status 302). This indicates to the client
1231N/A that the resource has moved temporarily. The <em>status</em>
1231N/A argument can be used to return other HTTP status codes:</p>
1231N/A
2221N/A <dl>
2221N/A <dt>permanent</dt>
2935N/A
2221N/A <dd>Returns a permanent redirect status (301) indicating that
2221N/A the resource has moved permanently.</dd>
2221N/A
2221N/A <dt>temp</dt>
1231N/A
1580N/A <dd>Returns a temporary redirect status (302). This is the
1580N/A default.</dd>
1580N/A
1580N/A <dt>seeother</dt>
1580N/A
1580N/A <dd>Returns a "See Other" status (303) indicating that the
1580N/A resource has been replaced.</dd>
1580N/A
1580N/A <dt>gone</dt>
1580N/A
1580N/A <dd>Returns a "Gone" status (410) indicating that the
1580N/A resource has been permanently removed. When this status is
1580N/A used the <em>url</em> argument should be omitted.</dd>
1580N/A </dl>
1580N/A
1580N/A <p>Other status codes can be returned by giving the numeric
1580N/A status code as the value of <em>status</em>. If the status is
1580N/A between 300 and 399, the <em>url</em> argument must be present,
1580N/A otherwise it must be omitted. Note that the status must be
1580N/A known to the Apache code (see the function
1580N/A <code>send_error_response</code> in http_protocol.c).</p>
1580N/A <hr />
1580N/A
1580N/A <h2><a id="redirectmatch"
1580N/A name="redirectmatch">RedirectMatch</a></h2>
1580N/A
1580N/A <p><a href="directive-dict.html#Syntax"
1580N/A rel="Help"><strong>Syntax:</strong></a> RedirectMatch
1580N/A [<em>status</em>] <em>regex URL</em><br />
1580N/A <a href="directive-dict.html#Context"
1580N/A rel="Help"><strong>Context:</strong></a> server config, virtual
1580N/A host, directory, .htaccess<br />
1580N/A <a href="directive-dict.html#Override"
1580N/A rel="Help"><strong>Override:</strong></a> FileInfo<br />
1580N/A <a href="directive-dict.html#Status"
1580N/A rel="Help"><strong>Status:</strong></a> Base<br />
1580N/A <a href="directive-dict.html#Module"
1580N/A rel="Help"><strong>Module:</strong></a> mod_alias</p>
1580N/A
1580N/A <p>This directive is equivalent to <a
1580N/A href="#redirect">Redirect</a>, but makes use of standard
1580N/A regular expressions, instead of simple prefix matching. The
1580N/A supplied regular expression is matched against the URL-path,
1580N/A and if it matches, the server will substitute any parenthesized
1580N/A matches into the given string and use it as a filename. For
1580N/A example, to redirect all GIF files to like-named JPEG files on
1580N/A another server, one might use:</p>
1580N/A<pre>
1580N/A RedirectMatch (.*)\.gif$ http://www.anotherserver.com$1.jpg
1580N/A</pre>
1580N/A <br />
1580N/A <br />
1580N/A
1580N/A <hr />
1580N/A
1580N/A <h2><a id="redirecttemp" name="redirecttemp">RedirectTemp
1580N/A directive</a></h2>
2221N/A
1580N/A <p><!--%plaintext &lt;?INDEX {\tt Redirect} directive&gt; -->
1580N/A <a href="directive-dict.html#Syntax"
2935N/A rel="Help"><strong>Syntax:</strong></a> RedirectTemp
1580N/A <em>URL-path URL</em><br />
1580N/A <a href="directive-dict.html#Context"
1580N/A rel="Help"><strong>Context:</strong></a> server config, virtual
1580N/A host, directory, .htaccess<br />
1580N/A <a href="directive-dict.html#Override"
1580N/A rel="Help"><strong>Override:</strong></a> FileInfo<br />
1580N/A <a href="directive-dict.html#Status"
1580N/A rel="Help"><strong>Status:</strong></a> Base<br />
1580N/A <a href="directive-dict.html#Module"
1580N/A rel="Help"><strong>Module:</strong></a> mod_alias</p>
1580N/A
1580N/A <p>This directive makes the client know that the Redirect is
1580N/A only temporary (status 302). Exactly equivalent to
1580N/A <code>Redirect temp</code>.</p>
1580N/A <hr />
2381N/A
2381N/A <h2><a id="redirectperm" name="redirectperm">RedirectPermanent
2381N/A directive</a></h2>
2381N/A
2381N/A <p><!--%plaintext &lt;?INDEX {\tt Redirect} directive&gt; -->
2381N/A <a href="directive-dict.html#Syntax"
2381N/A rel="Help"><strong>Syntax:</strong></a> RedirectPermanent
2381N/A <em>URL-path URL</em><br />
1580N/A <a href="directive-dict.html#Context"
1580N/A rel="Help"><strong>Context:</strong></a> server config, virtual
1580N/A host, directory, .htaccess<br />
1580N/A <a href="directive-dict.html#Override"
1580N/A rel="Help"><strong>Override:</strong></a> FileInfo<br />
1580N/A <a href="directive-dict.html#Status"
1580N/A rel="Help"><strong>Status:</strong></a> Base<br />
1580N/A <a href="directive-dict.html#Module"
2221N/A rel="Help"><strong>Module:</strong></a> mod_alias</p>
1580N/A
2221N/A <p>This directive makes the client know that the Redirect is
2221N/A permanent (status 301). Exactly equivalent to <code>Redirect
2221N/A permanent</code>.</p>
2221N/A <hr />
2221N/A
2221N/A <h2><a id="scriptalias" name="scriptalias">ScriptAlias
2221N/A directive</a></h2>
2221N/A
2221N/A <p>
2221N/A <!--%plaintext &lt;?INDEX {\tt ScriptAlias} directive&gt; -->
2221N/A <a href="directive-dict.html#Syntax"
2221N/A rel="Help"><strong>Syntax:</strong></a> ScriptAlias
1580N/A <em>URL-path file-path</em>|<em>directory-path</em><br />
1580N/A <a href="directive-dict.html#Context"
2236N/A rel="Help"><strong>Context:</strong></a> server config, virtual
1580N/A host<br />
1580N/A <a href="directive-dict.html#Status"
1580N/A rel="Help"><strong>Status:</strong></a> Base<br />
1580N/A <a href="directive-dict.html#Module"
1580N/A rel="Help"><strong>Module:</strong></a> mod_alias</p>
1580N/A
1580N/A <p>The ScriptAlias directive has the same behavior as the <a
1580N/A href="#alias">Alias</a> directive, except that in addition it
1580N/A marks the target directory as containing CGI scripts. URLs with
1580N/A a (%-decoded) path beginning with <em>URL-path</em> will be
1580N/A mapped to scripts beginning with the second argument which is a
1580N/A full pathname in the local filesystem.</p>
1580N/A
1580N/A <p>Example:</p>
1580N/A
1580N/A <blockquote>
1580N/A <code>ScriptAlias /cgi-bin/ /web/cgi-bin/</code>
1580N/A </blockquote>
1580N/A
1580N/A <p>A request for http://myserver/cgi-bin/foo would cause the
1580N/A server to run the script /web/cgi-bin/foo.</p>
1580N/A <hr />
1580N/A
1580N/A <h2><a id="scriptaliasmatch"
1580N/A name="scriptaliasmatch">ScriptAliasMatch</a></h2>
1580N/A
1580N/A <p><a href="directive-dict.html#Syntax"
1580N/A rel="Help"><strong>Syntax:</strong></a> ScriptAliasMatch
1580N/A <em>regex file-path</em>|<em>directory-path</em><br />
1580N/A <a href="directive-dict.html#Context"
1580N/A rel="Help"><strong>Context:</strong></a> server config, virtual
1580N/A host<br />
1580N/A <a href="directive-dict.html#Status"
1580N/A rel="Help"><strong>Status:</strong></a> Base<br />
1580N/A <a href="directive-dict.html#Module"
1580N/A rel="Help"><strong>Module:</strong></a> mod_alias</p>
2221N/A
1580N/A <p>This directive is equivalent to <a
1580N/A href="#scriptalias">ScriptAlias</a>, but makes use of standard
1580N/A regular expressions, instead of simple prefix matching. The
1580N/A supplied regular expression is matched against the URL-path,
1580N/A and if it matches, the server will substitute any parenthesized
2236N/A matches into the given string and use it as a filename. For
1580N/A example, to activate the standard <code>/cgi-bin</code>, one
1580N/A might use:</p>
1580N/A<pre>
1580N/A ScriptAliasMatch ^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
1580N/A</pre>
2236N/A <br />
2236N/A <br />
1580N/A <!--#include virtual="footer.html" -->
1580N/A </body>
1580N/A</html>
1580N/A
3158N/A