1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
4 <TITLE>Apache module mod_alias</TITLE>
7 <!-- Background white, links blue (unvisited), navy (visited), red (active) -->
15 <!--#include virtual="header.html" -->
17 <H1 ALIGN="CENTER">Module mod_alias</H1>
19 This module is contained in the <CODE>mod_alias.c</CODE> file, and
20 is compiled in by default. It provides for mapping different parts of the
21 host filesystem in the the document tree, and for URL redirection.
26 <LI><A HREF="#alias">Alias</A>
27 <LI><A HREF="#aliasmatch">AliasMatch</A>
28 <LI><A HREF="#redirect">Redirect</A>
29 <LI><A HREF="#redirectmatch">RedirectMatch</A>
30 <LI><A HREF="#redirecttemp">RedirectTemp</A>
31 <LI><A HREF="#redirectperm">RedirectPermanent</A>
32 <LI><A HREF="#scriptalias">ScriptAlias</A>
33 <LI><A HREF="#scriptaliasmatch">ScriptAliasMatch</A>
38 <H2><A name="alias">Alias directive</A></H2>
40 <!--%plaintext <?INDEX {\tt Alias} directive> -->
42 HREF="directive-dict.html#Syntax"
44 ><STRONG>Syntax:</STRONG></A> Alias <EM>url-path directory-filename</EM><BR>
46 HREF="directive-dict.html#Context"
48 ><STRONG>Context:</STRONG></A> server config, virtual host<BR>
50 HREF="directive-dict.html#Status"
52 ><STRONG>Status:</STRONG></A> Base<BR>
54 HREF="directive-dict.html#Module"
56 ><STRONG>Module:</STRONG></A> mod_alias
59 The Alias directive allows documents to be stored in the local filesystem
60 other than under the <A HREF="core.html#documentroot">DocumentRoot</A>.
61 URLs with a (%-decoded) path beginning with <EM>url-path</EM> will be
62 mapped to local files beginning with <EM>directory-filename</EM>.
66 <BLOCKQUOTE><CODE>Alias /image /ftp/pub/image</CODE></BLOCKQUOTE>
68 A request for http://myserver/image/foo.gif would cause the server to
69 return the file /ftp/pub/image/foo.gif.
72 Note that if you include a trailing / on the <EM>url-path</EM> then the
73 server will require a trailing / in order to expand the alias. That is,
74 if you use <CODE>Alias /icons/ /usr/local/apache/icons/</CODE> then
75 the url <CODE>/icons</CODE> will not be aliased.
78 See also <A HREF="#scriptalias">ScriptAlias</A>.
82 <H2><A name="aliasmatch">AliasMatch</A></H2>
85 HREF="directive-dict.html#Syntax"
87 ><STRONG>Syntax:</STRONG></A> AliasMatch <EM>regex directory-filename</EM><BR>
89 HREF="directive-dict.html#Context"
91 ><STRONG>Context:</STRONG></A> server config, virtual host<BR>
93 HREF="directive-dict.html#Status"
95 ><STRONG>Status:</STRONG></A> Base<BR>
97 HREF="directive-dict.html#Module"
99 ><STRONG>Module:</STRONG></A> mod_alias<BR>
101 HREF="directive-dict.html#Compatibility"
103 ><STRONG>Compatibility:</STRONG></A> Available in Apache 1.3 and later
106 <P>This directive is equivalent to <A HREF="#alias">Alias</A>, but
107 makes use of standard regular expressions, instead of simple prefix
108 matching. The supplied regular expression is matched against the URL,
109 and if it matches, the server will substitute any parenthesized
110 matches into the given string and use it as a filename. For example,
111 to activate the <CODE>/icons</CODE> directory, one might use:
113 AliasMatch ^/icons(.*) /usr/local/apache/icons$1
119 <H2><A name="redirect">Redirect directive</A></H2>
121 <!--%plaintext <?INDEX {\tt Redirect} directive> -->
123 HREF="directive-dict.html#Syntax"
125 ><STRONG>Syntax:</STRONG></A> Redirect [ <EM>status</EM> ] <EM>url-path url</EM><BR>
127 HREF="directive-dict.html#Context"
129 ><STRONG>Context:</STRONG></A> server config, virtual host, directory, .htaccess<BR>
131 HREF="directive-dict.html#Status"
133 ><STRONG>Status:</STRONG></A> Base<BR>
135 HREF="directive-dict.html#Module"
137 ><STRONG>Module:</STRONG></A> mod_alias<BR>
139 HREF="directive-dict.html#Compatibility"
141 ><STRONG>Compatibility:</STRONG></A> The directory and .htaccess context's
142 are only available in versions 1.1 and later. The <EM>status</EM>
143 argument is only available in Apache 1.2 or later.
146 The Redirect directive maps an old URL into a new one. The new URL is returned
147 to the client which attempts to fetch it again with the new address.
148 <EM>Url-path</EM> a (%-decoded) path; any requests for documents beginning with
149 this path will be returned a redirect error to a new (%-encoded) url
150 beginning with <EM>url</EM>.
155 <BLOCKQUOTE><CODE>Redirect /service
156 http://foo2.bar.com/service</CODE></BLOCKQUOTE>
158 If the client requests http://myserver/service/foo.txt, it will be told to
159 access http://foo2.bar.com/service/foo.txt instead.
162 <STRONG>Note:</STRONG> Redirect directives take precedence over Alias
164 directives, irrespective of their ordering in the configuration file. Also,
165 <EM>Url-path</EM> must be an absolute path, not a relative path, even
166 when used with .htaccess files or inside of <Directory> sections.
169 If no <EM>status</EM> argument is given, the redirect will be
170 "temporary" (HTTP status 302). This indicates to the client that the
171 resources is has moved temporarily. The <EM>status</EM>
172 argument can be used to return other HTTP status codes:
176 <DD>Returns a permanent redirect status (301) indicating that
177 the resource has moved permanently.
179 <DD>Returns a temporary redirect status (302). This is the
182 <DD>Returns a "See Other" status (303) indicating that
183 the resource has been replaced.
185 <DD>Returns a "Gone" status (410) indicating that the resource
186 has been permanently removed. When this status is used the <EM>url</EM>
187 argument should be omitted.
190 Other status codes can be returned by giving the numeric status code
191 as the value of <EM>status</EM>. If the status is between 300 and 399,
192 the <EM>url</EM> argument must be present, otherwise it must be
193 omitted. Note that the status must be known to the Apache code (see
194 the function <CODE>send_error_response</CODE> in http_protocol.c).
198 <H2><A name="redirectmatch">RedirectMatch</A></H2>
201 HREF="directive-dict.html#Syntax"
203 ><STRONG>Syntax:</STRONG></A> RedirectMatch [<EM>status</EM> <EM>regex url</EM><BR>
205 HREF="directive-dict.html#Context"
207 ><STRONG>Context:</STRONG></A> server config, virtual host<BR>
209 HREF="directive-dict.html#Status"
211 ><STRONG>Status:</STRONG></A> Base<BR>
213 HREF="directive-dict.html#Module"
215 ><STRONG>Module:</STRONG></A> mod_alias<BR>
217 HREF="directive-dict.html#Compatibility"
219 ><STRONG>Compatibility:</STRONG></A> Available in Apache 1.3 and later
222 <P>This directive is equivalent to <A HREF="#alias">Redirect</A>, but
223 makes use of standard regular expressions, instead of simple prefix
224 matching. The supplied regular expression is matched against the URL,
225 and if it matches, the server will substitute any parenthesized
226 matches into the given string and use it as a filename. For example,
227 to redirect all GIF files to like-named JPEG files on another server,
230 RedirectMatch (.*)\.gif$ http://www.anotherserver.com$1.jpg
236 <H2><A name="redirecttemp">RedirectTemp directive</A></H2>
238 <!--%plaintext <?INDEX {\tt Redirect} directive> -->
240 HREF="directive-dict.html#Syntax"
242 ><STRONG>Syntax:</STRONG></A> RedirectTemp <EM>url-path url</EM><BR>
244 HREF="directive-dict.html#Context"
246 ><STRONG>Context:</STRONG></A> server config, virtual host, directory, .htaccess<BR>
248 HREF="directive-dict.html#Status"
250 ><STRONG>Status:</STRONG></A> Base<BR>
252 HREF="directive-dict.html#Module"
254 ><STRONG>Module:</STRONG></A> mod_alias<BR>
256 HREF="directive-dict.html#Compatibility"
258 ><STRONG>Compatibility:</STRONG></A> This directive is only available in 1.2
261 This directive makes the client know that the Redirect is only
262 temporary (status 302). Exactly equivalent to <CODE>Redirect
267 <H2><A name="redirectperm">RedirectPermanent directive</A></H2>
269 <!--%plaintext <?INDEX {\tt Redirect} directive> -->
271 HREF="directive-dict.html#Syntax"
273 ><STRONG>Syntax:</STRONG></A> RedirectPermanent <EM>url-path url</EM><BR>
275 HREF="directive-dict.html#Context"
277 ><STRONG>Context:</STRONG></A> server config, virtual host, directory, .htaccess<BR>
279 HREF="directive-dict.html#Status"
281 ><STRONG>Status:</STRONG></A> Base<BR>
283 HREF="directive-dict.html#Module"
285 ><STRONG>Module:</STRONG></A> mod_alias<BR>
287 HREF="directive-dict.html#Compatibility"
289 ><STRONG>Compatibility:</STRONG></A> This directive is only available in 1.2
292 This directive makes the client know that the Redirect is permanent
293 (status 301). Exactly equivalent to <CODE>Redirect permanent</CODE>.
297 <H2><A name="scriptalias">ScriptAlias directive</A></H2>
299 <!--%plaintext <?INDEX {\tt ScriptAlias} directive> -->
301 HREF="directive-dict.html#Syntax"
303 ><STRONG>Syntax:</STRONG></A> ScriptAlias <EM>url-path directory-filename</EM><BR>
305 HREF="directive-dict.html#Context"
307 ><STRONG>Context:</STRONG></A> server config, virtual host<BR>
309 HREF="directive-dict.html#Status"
311 ><STRONG>Status:</STRONG></A> Base<BR>
313 HREF="directive-dict.html#Module"
315 ><STRONG>Module:</STRONG></A> mod_alias
318 The ScriptAlias directive has the same behavior as the
319 <A HREF="#alias">Alias</A> directive, except that in addition it
320 marks the target directory as containing CGI scripts.
321 URLs with a (%-decoded) path beginning with <EM>url-path</EM> will be
322 mapped to scripts beginning with <EM>directory-filename</EM>.
326 <BLOCKQUOTE><CODE>ScriptAlias /cgi-bin/ /web/cgi-bin/</CODE></BLOCKQUOTE>
328 A request for http://myserver/cgi-bin/foo would cause the server to
329 run the script /web/cgi-bin/foo.
334 <H2><A name="scriptaliasmatch">ScriptAliasMatch</A></H2>
337 HREF="directive-dict.html#Syntax"
339 ><STRONG>Syntax:</STRONG></A> ScriptAliasMatch <EM>regex directory-filename</EM><BR>
341 HREF="directive-dict.html#Context"
343 ><STRONG>Context:</STRONG></A> server config, virtual host<BR>
345 HREF="directive-dict.html#Status"
347 ><STRONG>Status:</STRONG></A> Base<BR>
349 HREF="directive-dict.html#Module"
351 ><STRONG>Module:</STRONG></A> mod_alias<BR>
353 HREF="directive-dict.html#Compatibility"
355 ><STRONG>Compatibility:</STRONG></A> Available in Apache 1.3 and later
358 <P>This directive is equivalent to <A HREF="#scriptalias">ScriptAlias</A>, but
359 makes use of standard regular expressions, instead of simple prefix
360 matching. The supplied regular expression is matched against the URL,
361 and if it matches, the server will substitute any parenthesized
362 matches into the given string and use it as a filename. For example,
363 to activate the standard <CODE>/cgi-bin</CODE>, one might use:
365 ScriptAliasMatch ^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
369 <!--#include virtual="footer.html" -->