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 Note that you may need to specify additional
79 <A HREF="core.html#directory"><CODE><Directory></CODE></A> sections
80 which cover the <EM>destination</EM> of aliases. Aliasing occurs
81 before <CODE><Directory></CODE> sections are checked, so only
82 the destination of aliases are affected. (Note however
83 <A HREF="core.html#location"><CODE><Location></CODE></A>
84 sections are run through once before aliases are performed, so they
87 See also <A HREF="#scriptalias">ScriptAlias</A>.
91 <H2><A NAME="aliasmatch">AliasMatch</A></H2>
94 HREF="directive-dict.html#Syntax"
96 ><STRONG>Syntax:</STRONG></A> AliasMatch <EM>regex directory-filename</EM><BR>
98 HREF="directive-dict.html#Context"
100 ><STRONG>Context:</STRONG></A> server config, virtual host<BR>
102 HREF="directive-dict.html#Status"
104 ><STRONG>Status:</STRONG></A> Base<BR>
106 HREF="directive-dict.html#Module"
108 ><STRONG>Module:</STRONG></A> mod_alias<BR>
110 HREF="directive-dict.html#Compatibility"
112 ><STRONG>Compatibility:</STRONG></A> Available in Apache 1.3 and later
115 <P>This directive is equivalent to <A HREF="#alias">Alias</A>, but
116 makes use of standard regular expressions, instead of simple prefix
117 matching. The supplied regular expression is matched against the URL,
118 and if it matches, the server will substitute any parenthesized
119 matches into the given string and use it as a filename. For example,
120 to activate the <CODE>/icons</CODE> directory, one might use:
122 AliasMatch ^/icons(.*) /usr/local/apache/icons$1
128 <H2><A NAME="redirect">Redirect directive</A></H2>
130 <!--%plaintext <?INDEX {\tt Redirect} directive> -->
132 HREF="directive-dict.html#Syntax"
134 ><STRONG>Syntax:</STRONG></A> Redirect [ <EM>status</EM> ]
135 <EM>url-path url</EM><BR>
137 HREF="directive-dict.html#Context"
139 ><STRONG>Context:</STRONG></A> server config, virtual host, directory,
142 HREF="directive-dict.html#Override"
144 ><STRONG>Override:</STRONG></A> FileInfo<BR>
146 HREF="directive-dict.html#Status"
148 ><STRONG>Status:</STRONG></A> Base<BR>
150 HREF="directive-dict.html#Module"
152 ><STRONG>Module:</STRONG></A> mod_alias<BR>
154 HREF="directive-dict.html#Compatibility"
156 ><STRONG>Compatibility:</STRONG></A> The directory and .htaccess context's
157 are only available in versions 1.1 and later. The <EM>status</EM>
158 argument is only available in Apache 1.2 or later.
161 The Redirect directive maps an old URL into a new one. The new URL is returned
162 to the client which attempts to fetch it again with the new address.
163 <EM>Url-path</EM> a (%-decoded) path; any requests for documents beginning with
164 this path will be returned a redirect error to a new (%-encoded) url
165 beginning with <EM>url</EM>.
170 <BLOCKQUOTE><CODE>Redirect /service
171 http://foo2.bar.com/service</CODE></BLOCKQUOTE>
173 If the client requests http://myserver/service/foo.txt, it will be told to
174 access http://foo2.bar.com/service/foo.txt instead.
177 <STRONG>Note:</STRONG> Redirect directives take precedence over Alias
179 directives, irrespective of their ordering in the configuration file. Also,
180 <EM>Url-path</EM> must be an absolute path, not a relative path, even
181 when used with .htaccess files or inside of <Directory> sections.
184 If no <EM>status</EM> argument is given, the redirect will be
185 "temporary" (HTTP status 302). This indicates to the client that the
186 resources is has moved temporarily. The <EM>status</EM>
187 argument can be used to return other HTTP status codes:
191 <DD>Returns a permanent redirect status (301) indicating that
192 the resource has moved permanently.
194 <DD>Returns a temporary redirect status (302). This is the
197 <DD>Returns a "See Other" status (303) indicating that
198 the resource has been replaced.
200 <DD>Returns a "Gone" status (410) indicating that the resource
201 has been permanently removed. When this status is used the <EM>url</EM>
202 argument should be omitted.
205 Other status codes can be returned by giving the numeric status code
206 as the value of <EM>status</EM>. If the status is between 300 and 399,
207 the <EM>url</EM> argument must be present, otherwise it must be
208 omitted. Note that the status must be known to the Apache code (see
209 the function <CODE>send_error_response</CODE> in http_protocol.c).
213 <H2><A NAME="redirectmatch">RedirectMatch</A></H2>
216 HREF="directive-dict.html#Syntax"
218 ><STRONG>Syntax:</STRONG></A>
219 RedirectMatch [<EM>status</EM>] <EM>regex url</EM>
222 HREF="directive-dict.html#Context"
224 ><STRONG>Context:</STRONG></A> server config, virtual host<BR>
226 HREF="directive-dict.html#Override"
228 ><STRONG>Override:</STRONG></A> FileInfo<BR>
230 HREF="directive-dict.html#Status"
232 ><STRONG>Status:</STRONG></A> Base<BR>
234 HREF="directive-dict.html#Module"
236 ><STRONG>Module:</STRONG></A> mod_alias<BR>
238 HREF="directive-dict.html#Compatibility"
240 ><STRONG>Compatibility:</STRONG></A> Available in Apache 1.3 and later
243 <P>This directive is equivalent to <A HREF="#alias">Redirect</A>, but
244 makes use of standard regular expressions, instead of simple prefix
245 matching. The supplied regular expression is matched against the URL,
246 and if it matches, the server will substitute any parenthesized
247 matches into the given string and use it as a filename. For example,
248 to redirect all GIF files to like-named JPEG files on another server,
251 RedirectMatch (.*)\.gif$ http://www.anotherserver.com$1.jpg
257 <H2><A NAME="redirecttemp">RedirectTemp directive</A></H2>
259 <!--%plaintext <?INDEX {\tt Redirect} directive> -->
261 HREF="directive-dict.html#Syntax"
263 ><STRONG>Syntax:</STRONG></A> RedirectTemp <EM>url-path url</EM><BR>
265 HREF="directive-dict.html#Context"
267 ><STRONG>Context:</STRONG></A> server config, virtual host, directory,
270 HREF="directive-dict.html#Override"
272 ><STRONG>Override:</STRONG></A> FileInfo<BR>
274 HREF="directive-dict.html#Status"
276 ><STRONG>Status:</STRONG></A> Base<BR>
278 HREF="directive-dict.html#Module"
280 ><STRONG>Module:</STRONG></A> mod_alias<BR>
282 HREF="directive-dict.html#Compatibility"
284 ><STRONG>Compatibility:</STRONG></A> This directive is only available in 1.2
287 This directive makes the client know that the Redirect is only
288 temporary (status 302). Exactly equivalent to <CODE>Redirect
293 <H2><A NAME="redirectperm">RedirectPermanent directive</A></H2>
295 <!--%plaintext <?INDEX {\tt Redirect} directive> -->
297 HREF="directive-dict.html#Syntax"
299 ><STRONG>Syntax:</STRONG></A> RedirectPermanent <EM>url-path url</EM><BR>
301 HREF="directive-dict.html#Context"
303 ><STRONG>Context:</STRONG></A> server config, virtual host, directory,
306 HREF="directive-dict.html#Override"
308 ><STRONG>Override:</STRONG></A> FileInfo<BR>
310 HREF="directive-dict.html#Status"
312 ><STRONG>Status:</STRONG></A> Base<BR>
314 HREF="directive-dict.html#Module"
316 ><STRONG>Module:</STRONG></A> mod_alias<BR>
318 HREF="directive-dict.html#Compatibility"
320 ><STRONG>Compatibility:</STRONG></A> This directive is only available in 1.2
323 This directive makes the client know that the Redirect is permanent
324 (status 301). Exactly equivalent to <CODE>Redirect permanent</CODE>.
328 <H2><A NAME="scriptalias">ScriptAlias directive</A></H2>
330 <!--%plaintext <?INDEX {\tt ScriptAlias} directive> -->
332 HREF="directive-dict.html#Syntax"
334 ><STRONG>Syntax:</STRONG></A> ScriptAlias <EM>url-path directory-filename</EM>
337 HREF="directive-dict.html#Context"
339 ><STRONG>Context:</STRONG></A> server config, virtual host<BR>
341 HREF="directive-dict.html#Status"
343 ><STRONG>Status:</STRONG></A> Base<BR>
345 HREF="directive-dict.html#Module"
347 ><STRONG>Module:</STRONG></A> mod_alias
350 The ScriptAlias directive has the same behavior as the
351 <A HREF="#alias">Alias</A> directive, except that in addition it
352 marks the target directory as containing CGI scripts.
353 URLs with a (%-decoded) path beginning with <EM>url-path</EM> will be
354 mapped to scripts beginning with <EM>directory-filename</EM>.
358 <BLOCKQUOTE><CODE>ScriptAlias /cgi-bin/ /web/cgi-bin/</CODE></BLOCKQUOTE>
360 A request for http://myserver/cgi-bin/foo would cause the server to
361 run the script /web/cgi-bin/foo.
366 <H2><A NAME="scriptaliasmatch">ScriptAliasMatch</A></H2>
369 HREF="directive-dict.html#Syntax"
371 ><STRONG>Syntax:</STRONG></A> ScriptAliasMatch
372 <EM>regex directory-filename</EM><BR>
374 HREF="directive-dict.html#Context"
376 ><STRONG>Context:</STRONG></A> server config, virtual host<BR>
378 HREF="directive-dict.html#Status"
380 ><STRONG>Status:</STRONG></A> Base<BR>
382 HREF="directive-dict.html#Module"
384 ><STRONG>Module:</STRONG></A> mod_alias<BR>
386 HREF="directive-dict.html#Compatibility"
388 ><STRONG>Compatibility:</STRONG></A> Available in Apache 1.3 and later
391 <P>This directive is equivalent to <A HREF="#scriptalias">ScriptAlias</A>, but
392 makes use of standard regular expressions, instead of simple prefix
393 matching. The supplied regular expression is matched against the URL,
394 and if it matches, the server will substitute any parenthesized
395 matches into the given string and use it as a filename. For example,
396 to activate the standard <CODE>/cgi-bin</CODE>, one might use:
398 ScriptAliasMatch ^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
402 <!--#include virtual="footer.html" -->