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 resource 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, directory,
227 HREF="directive-dict.html#Override"
229 ><STRONG>Override:</STRONG></A> FileInfo<BR>
231 HREF="directive-dict.html#Status"
233 ><STRONG>Status:</STRONG></A> Base<BR>
235 HREF="directive-dict.html#Module"
237 ><STRONG>Module:</STRONG></A> mod_alias<BR>
239 HREF="directive-dict.html#Compatibility"
241 ><STRONG>Compatibility:</STRONG></A> Available in Apache 1.3 and later
244 <P>This directive is equivalent to <A HREF="#alias">Redirect</A>, but
245 makes use of standard regular expressions, instead of simple prefix
246 matching. The supplied regular expression is matched against the URL,
247 and if it matches, the server will substitute any parenthesized
248 matches into the given string and use it as a filename. For example,
249 to redirect all GIF files to like-named JPEG files on another server,
252 RedirectMatch (.*)\.gif$ http://www.anotherserver.com$1.jpg
258 <H2><A NAME="redirecttemp">RedirectTemp directive</A></H2>
260 <!--%plaintext <?INDEX {\tt Redirect} directive> -->
262 HREF="directive-dict.html#Syntax"
264 ><STRONG>Syntax:</STRONG></A> RedirectTemp <EM>url-path url</EM><BR>
266 HREF="directive-dict.html#Context"
268 ><STRONG>Context:</STRONG></A> server config, virtual host, directory,
271 HREF="directive-dict.html#Override"
273 ><STRONG>Override:</STRONG></A> FileInfo<BR>
275 HREF="directive-dict.html#Status"
277 ><STRONG>Status:</STRONG></A> Base<BR>
279 HREF="directive-dict.html#Module"
281 ><STRONG>Module:</STRONG></A> mod_alias<BR>
283 HREF="directive-dict.html#Compatibility"
285 ><STRONG>Compatibility:</STRONG></A> This directive is only available in Apache 1.2 and later
288 This directive makes the client know that the Redirect is only
289 temporary (status 302). Exactly equivalent to <CODE>Redirect
294 <H2><A NAME="redirectperm">RedirectPermanent directive</A></H2>
296 <!--%plaintext <?INDEX {\tt Redirect} directive> -->
298 HREF="directive-dict.html#Syntax"
300 ><STRONG>Syntax:</STRONG></A> RedirectPermanent <EM>url-path url</EM><BR>
302 HREF="directive-dict.html#Context"
304 ><STRONG>Context:</STRONG></A> server config, virtual host, directory,
307 HREF="directive-dict.html#Override"
309 ><STRONG>Override:</STRONG></A> FileInfo<BR>
311 HREF="directive-dict.html#Status"
313 ><STRONG>Status:</STRONG></A> Base<BR>
315 HREF="directive-dict.html#Module"
317 ><STRONG>Module:</STRONG></A> mod_alias<BR>
319 HREF="directive-dict.html#Compatibility"
321 ><STRONG>Compatibility:</STRONG></A> This directive is only available in Apache 1.2 and later
324 This directive makes the client know that the Redirect is permanent
325 (status 301). Exactly equivalent to <CODE>Redirect permanent</CODE>.
329 <H2><A NAME="scriptalias">ScriptAlias directive</A></H2>
331 <!--%plaintext <?INDEX {\tt ScriptAlias} directive> -->
333 HREF="directive-dict.html#Syntax"
335 ><STRONG>Syntax:</STRONG></A> ScriptAlias <EM>url-path directory-filename</EM>
338 HREF="directive-dict.html#Context"
340 ><STRONG>Context:</STRONG></A> server config, virtual host<BR>
342 HREF="directive-dict.html#Status"
344 ><STRONG>Status:</STRONG></A> Base<BR>
346 HREF="directive-dict.html#Module"
348 ><STRONG>Module:</STRONG></A> mod_alias
351 The ScriptAlias directive has the same behavior as the
352 <A HREF="#alias">Alias</A> directive, except that in addition it
353 marks the target directory as containing CGI scripts.
354 URLs with a (%-decoded) path beginning with <EM>url-path</EM> will be
355 mapped to scripts beginning with <EM>directory-filename</EM>.
359 <BLOCKQUOTE><CODE>ScriptAlias /cgi-bin/ /web/cgi-bin/</CODE></BLOCKQUOTE>
361 A request for http://myserver/cgi-bin/foo would cause the server to
362 run the script /web/cgi-bin/foo.
367 <H2><A NAME="scriptaliasmatch">ScriptAliasMatch</A></H2>
370 HREF="directive-dict.html#Syntax"
372 ><STRONG>Syntax:</STRONG></A> ScriptAliasMatch
373 <EM>regex directory-filename</EM><BR>
375 HREF="directive-dict.html#Context"
377 ><STRONG>Context:</STRONG></A> server config, virtual host<BR>
379 HREF="directive-dict.html#Status"
381 ><STRONG>Status:</STRONG></A> Base<BR>
383 HREF="directive-dict.html#Module"
385 ><STRONG>Module:</STRONG></A> mod_alias<BR>
387 HREF="directive-dict.html#Compatibility"
389 ><STRONG>Compatibility:</STRONG></A> Available in Apache 1.3 and later
392 <P>This directive is equivalent to <A HREF="#scriptalias">ScriptAlias</A>, but
393 makes use of standard regular expressions, instead of simple prefix
394 matching. The supplied regular expression is matched against the URL,
395 and if it matches, the server will substitute any parenthesized
396 matches into the given string and use it as a filename. For example,
397 to activate the standard <CODE>/cgi-bin</CODE>, one might use:
399 ScriptAliasMatch ^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
403 <!--#include virtual="footer.html" -->