mod_alias.html revision 7ec51ea96adc75769efcdc27edf7faba3badc3bf
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
530eba85dbd41b8a0fa5255d3648d1440199a661slive BGCOLOR="#FFFFFF"
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive TEXT="#000000"
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive LINK="#0000FF"
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive VLINK="#000080"
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess ALINK="#FF0000"
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<!--#include virtual="header.html" -->
18b4b0fd6056093002ddef488636bf5ebe415ef0erikabeleThis module is contained in the <CODE>mod_alias.c</CODE> file, and
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveis compiled in by default. It provides for mapping different parts of the
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivehost filesystem in the the document tree, and for URL redirection.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<!--%plaintext <?INDEX {\tt Alias} directive> -->
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive><STRONG>Syntax:</STRONG></A> Alias <EM>url-path directory-filename</EM><BR>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive HREF="directive-dict.html#Context"
fb77c505254b6e9c925e23e734463e87574f8f40kess REL="Help"
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive><STRONG>Context:</STRONG></A> server config, virtual host<BR>
fb77c505254b6e9c925e23e734463e87574f8f40kess REL="Help"
fb77c505254b6e9c925e23e734463e87574f8f40kess REL="Help"
fb77c505254b6e9c925e23e734463e87574f8f40kessThe Alias directive allows documents to be stored in the local filesystem
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveother than under the <A HREF="core.html#documentroot">DocumentRoot</A>.
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveURLs with a (%-decoded) path beginning with <EM>url-path</EM> will be
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivemapped to local files beginning with <EM>directory-filename</EM>.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<BLOCKQUOTE><CODE>Alias /image /ftp/pub/image</CODE></BLOCKQUOTE>
fb77c505254b6e9c925e23e734463e87574f8f40kessA request for http://myserver/image/foo.gif would cause the server to
130d299c4b2b15be45532a176604c71fdc7bea5bndNote that if you include a trailing / on the <EM>url-path</EM> then the
130d299c4b2b15be45532a176604c71fdc7bea5bndserver will require a trailing / in order to expand the alias. That is,
130d299c4b2b15be45532a176604c71fdc7bea5bndif you use <CODE>Alias /icons/ /usr/local/apache/icons/</CODE> then
130d299c4b2b15be45532a176604c71fdc7bea5bndNote that you may need to specify additional
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd<A HREF="core.html#directory"><CODE><Directory></CODE></A> sections
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndwhich cover the <EM>destination</EM> of aliases. Aliasing occurs
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivebefore <CODE><Directory></CODE> sections are checked, so only
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivethe destination of aliases are affected. (Note however
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<A HREF="core.html#location"><CODE><Location></CODE></A>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivesections are run through once before aliases are performed, so they
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivewill apply.)
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess><STRONG>Syntax:</STRONG></A> AliasMatch <EM>regex directory-filename</EM><BR>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive HREF="directive-dict.html#Context"
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd REL="Help"
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd><STRONG>Context:</STRONG></A> server config, virtual host<BR>
130d299c4b2b15be45532a176604c71fdc7bea5bnd HREF="directive-dict.html#Compatibility"
130d299c4b2b15be45532a176604c71fdc7bea5bnd REL="Help"
130d299c4b2b15be45532a176604c71fdc7bea5bnd><STRONG>Compatibility:</STRONG></A> Available in Apache 1.3 and later
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd<P>This directive is equivalent to <A HREF="#alias">Alias</A>, but
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivemakes use of standard regular expressions, instead of simple prefix
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivematching. The supplied regular expression is matched against the URL,
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveand if it matches, the server will substitute any parenthesized
1a3f62ca37273a15a06bb94a61d3c6fcf4bf38c9rbowenmatches into the given string and use it as a filename. For example,
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveto activate the <CODE>/icons</CODE> directory, one might use:
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<!--%plaintext <?INDEX {\tt Redirect} directive> -->
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive><STRONG>Syntax:</STRONG></A> Redirect [ <EM>status</EM> ]
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive HREF="directive-dict.html#Context"
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive><STRONG>Context:</STRONG></A> server config, virtual host, directory,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive .htaccess<BR>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive HREF="directive-dict.html#Override"
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd REL="Help"
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd REL="Help"
58699879a562774640b95e9eedfd891f336e38c2nd REL="Help"
fb77c505254b6e9c925e23e734463e87574f8f40kess HREF="directive-dict.html#Compatibility"
fb77c505254b6e9c925e23e734463e87574f8f40kess REL="Help"
58699879a562774640b95e9eedfd891f336e38c2nd><STRONG>Compatibility:</STRONG></A> The directory and .htaccess context's
58699879a562774640b95e9eedfd891f336e38c2ndare only available in versions 1.1 and later. The <EM>status</EM>
58699879a562774640b95e9eedfd891f336e38c2ndargument is only available in Apache 1.2 or later.
58699879a562774640b95e9eedfd891f336e38c2ndThe Redirect directive maps an old URL into a new one. The new URL is returned
58699879a562774640b95e9eedfd891f336e38c2ndto the client which attempts to fetch it again with the new address.
58699879a562774640b95e9eedfd891f336e38c2nd<EM>Url-path</EM> a (%-decoded) path; any requests for documents beginning with
58699879a562774640b95e9eedfd891f336e38c2ndthis path will be returned a redirect error to a new (%-encoded) url
58699879a562774640b95e9eedfd891f336e38c2ndIf the client requests http://myserver/service/foo.txt, it will be told to
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess<STRONG>Note:</STRONG> Redirect directives take precedence over Alias
6b64034fa2a644ba291c484c0c01c7df5b8d982ckessand ScriptAlias
58699879a562774640b95e9eedfd891f336e38c2nddirectives, irrespective of their ordering in the configuration file. Also,
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess<EM>Url-path</EM> must be an absolute path, not a relative path, even
58699879a562774640b95e9eedfd891f336e38c2ndwhen used with .htaccess files or inside of <Directory> sections.
fb77c505254b6e9c925e23e734463e87574f8f40kessIf no <EM>status</EM> argument is given, the redirect will be
fb77c505254b6e9c925e23e734463e87574f8f40kess"temporary" (HTTP status 302). This indicates to the client that the
58699879a562774640b95e9eedfd891f336e38c2ndargument can be used to return other HTTP status codes:
58699879a562774640b95e9eedfd891f336e38c2nd<DT>permanent
58699879a562774640b95e9eedfd891f336e38c2nd<DD>Returns a permanent redirect status (301) indicating that
58699879a562774640b95e9eedfd891f336e38c2ndthe resource has moved permanently.
58699879a562774640b95e9eedfd891f336e38c2nd<DD>Returns a temporary redirect status (302). This is the
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess<DT>seeother
4a7affccb2f1f5b94cab395e1bf3825aed715ebcnd<DD>Returns a "See Other" status (303) indicating that
4a7affccb2f1f5b94cab395e1bf3825aed715ebcndthe resource has been replaced.
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess<DD>Returns a "Gone" status (410) indicating that the resource
6b64034fa2a644ba291c484c0c01c7df5b8d982ckesshas been permanently removed. When this status is used the <EM>url</EM>
6b64034fa2a644ba291c484c0c01c7df5b8d982ckessargument should be omitted.
4a7affccb2f1f5b94cab395e1bf3825aed715ebcndOther status codes can be returned by giving the numeric status code
4a7affccb2f1f5b94cab395e1bf3825aed715ebcndas the value of <EM>status</EM>. If the status is between 300 and 399,
4a7affccb2f1f5b94cab395e1bf3825aed715ebcndthe <EM>url</EM> argument must be present, otherwise it must be
4a7affccb2f1f5b94cab395e1bf3825aed715ebcndomitted. Note that the status must be known to the Apache code (see
4a7affccb2f1f5b94cab395e1bf3825aed715ebcndthe function <CODE>send_error_response</CODE> in http_protocol.c).
58699879a562774640b95e9eedfd891f336e38c2nd REL="Help"
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess HREF="directive-dict.html#Context"
fb77c505254b6e9c925e23e734463e87574f8f40kess REL="Help"
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd><STRONG>Context:</STRONG></A> server config, virtual host<BR>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive HREF="directive-dict.html#Override"
fb77c505254b6e9c925e23e734463e87574f8f40kess REL="Help"
10673857794a4b3d9568ca2d983722a87ed352f1rbowen HREF="directive-dict.html#Compatibility"
10673857794a4b3d9568ca2d983722a87ed352f1rbowen><STRONG>Compatibility:</STRONG></A> Available in Apache 1.3 and later
fb77c505254b6e9c925e23e734463e87574f8f40kess<P>This directive is equivalent to <A HREF="#alias">Redirect</A>, but
fb77c505254b6e9c925e23e734463e87574f8f40kessmakes use of standard regular expressions, instead of simple prefix
fb77c505254b6e9c925e23e734463e87574f8f40kessmatching. The supplied regular expression is matched against the URL,
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveand if it matches, the server will substitute any parenthesized
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivematches into the given string and use it as a filename. For example,
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveto redirect all GIF files to like-named JPEG files on another server,
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveone might use:
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive RedirectMatch (.*)\.gif$ http://www.anotherserver.com$1.jpg
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<H2><A NAME="redirecttemp">RedirectTemp directive</A></H2>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<!--%plaintext <?INDEX {\tt Redirect} directive> -->
9ed9eaf871c58d281af02e76125ceadb5060afa5nd><STRONG>Syntax:</STRONG></A> RedirectTemp <EM>url-path url</EM><BR>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive HREF="directive-dict.html#Context"
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive><STRONG>Context:</STRONG></A> server config, virtual host, directory,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive .htaccess<BR>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive HREF="directive-dict.html#Override"
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess REL="Help"
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive HREF="directive-dict.html#Compatibility"
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive><STRONG>Compatibility:</STRONG></A> This directive is only available in 1.2
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveThis directive makes the client know that the Redirect is only
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivetemporary (status 302). Exactly equivalent to <CODE>Redirect
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivetemp</CODE>.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<H2><A NAME="redirectperm">RedirectPermanent directive</A></H2>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<!--%plaintext <?INDEX {\tt Redirect} directive> -->
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive><STRONG>Syntax:</STRONG></A> RedirectPermanent <EM>url-path url</EM><BR>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive HREF="directive-dict.html#Context"
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive><STRONG>Context:</STRONG></A> server config, virtual host, directory,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive .htaccess<BR>
9ed9eaf871c58d281af02e76125ceadb5060afa5nd HREF="directive-dict.html#Override"
9ed9eaf871c58d281af02e76125ceadb5060afa5nd REL="Help"
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive HREF="directive-dict.html#Compatibility"
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd REL="Help"
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd><STRONG>Compatibility:</STRONG></A> This directive is only available in 1.2
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveThis directive makes the client know that the Redirect is permanent
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive(status 301). Exactly equivalent to <CODE>Redirect permanent</CODE>.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<H2><A NAME="scriptalias">ScriptAlias directive</A></H2>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<!--%plaintext <?INDEX {\tt ScriptAlias} directive> -->
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd REL="Help"
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive><STRONG>Syntax:</STRONG></A> ScriptAlias <EM>url-path directory-filename</EM>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive HREF="directive-dict.html#Context"
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive><STRONG>Context:</STRONG></A> server config, virtual host<BR>
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveThe ScriptAlias directive has the same behavior as the
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<A HREF="#alias">Alias</A> directive, except that in addition it
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivemarks the target directory as containing CGI scripts.
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndURLs with a (%-decoded) path beginning with <EM>url-path</EM> will be
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndmapped to scripts beginning with <EM>directory-filename</EM>.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<BLOCKQUOTE><CODE>ScriptAlias /cgi-bin/ /web/cgi-bin/</CODE></BLOCKQUOTE>
313bb560bc5c323cfd40c9cad7335b4b8e060aedkessA request for http://myserver/cgi-bin/foo would cause the server to
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<H2><A NAME="scriptaliasmatch">ScriptAliasMatch</A></H2>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive HREF="directive-dict.html#Context"
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess><STRONG>Context:</STRONG></A> server config, virtual host<BR>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive HREF="directive-dict.html#Compatibility"
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive><STRONG>Compatibility:</STRONG></A> Available in Apache 1.3 and later
fb77c505254b6e9c925e23e734463e87574f8f40kess<P>This directive is equivalent to <A HREF="#scriptalias">ScriptAlias</A>, but
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholesmakes use of standard regular expressions, instead of simple prefix
fb77c505254b6e9c925e23e734463e87574f8f40kessmatching. The supplied regular expression is matched against the URL,
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholesand if it matches, the server will substitute any parenthesized
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholesmatches into the given string and use it as a filename. For example,
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholesto activate the standard <CODE>/cgi-bin</CODE>, one might use:
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes ScriptAliasMatch ^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
fb77c505254b6e9c925e23e734463e87574f8f40kess<!--#include virtual="footer.html" -->