1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml">
6 <meta name="generator" content="HTML Tidy, see www.w3.org" />
8 <title>Apache module mod_alias</title>
10 <!-- Background white, links blue (unvisited), navy (visited), red (active) -->
12 <body bgcolor="#FFFFFF" text="#000000" link="#0000FF"
13 vlink="#000080" alink="#FF0000">
14 <!--#include virtual="header.html" -->
16 <h1 align="CENTER">Module mod_alias</h1>
18 <p>This module provides for mapping different parts of the host
19 filesystem in the document tree, and for URL redirection.</p>
21 <p><a href="module-dict.html#Status"
22 rel="Help"><strong>Status:</strong></a> Base<br />
23 <a href="module-dict.html#SourceFile"
24 rel="Help"><strong>Source File:</strong></a> mod_alias.c<br />
25 <a href="module-dict.html#ModuleIdentifier"
26 rel="Help"><strong>Module Identifier:</strong></a>
31 <p>The directives contained in this module allow for
32 manipulation and control of URLs as requests arrive at the
33 server. The <code>Alias</code> and <code>ScriptAlias</code>
34 directives are used to map between URLs and filesystem paths.
35 This allows for content which is not directly under the <a
36 href="core.html#documentroot"><code>DocumentRoot</code></a> to
37 be served as part of the web document tree. The
38 <code>ScriptAlias</code> directive has the additional effect of
39 marking the target directory as containing only CGI
42 <p>The <code>Redirect</code> directives are used to instruct
43 clients to make a new request with a different URL. They are
44 often used when a resource has moved to a new location.</p>
46 <p>A more powerful and flexible set of directives for
47 manipulating URLs is contained in the <a
48 href="mod_rewrite.html"><code>mod_rewrite</code></a>
54 <li><a href="#alias">Alias</a></li>
56 <li><a href="#aliasmatch">AliasMatch</a></li>
58 <li><a href="#redirect">Redirect</a></li>
60 <li><a href="#redirectmatch">RedirectMatch</a></li>
62 <li><a href="#redirecttemp">RedirectTemp</a></li>
64 <li><a href="#redirectperm">RedirectPermanent</a></li>
66 <li><a href="#scriptalias">ScriptAlias</a></li>
68 <li><a href="#scriptaliasmatch">ScriptAliasMatch</a></li>
72 <h2><a id="alias" name="alias">Alias directive</a></h2>
74 <p><!--%plaintext <?INDEX {\tt Alias} directive> -->
75 <a href="directive-dict.html#Syntax"
76 rel="Help"><strong>Syntax:</strong></a> Alias <em>URL-path
77 file-path</em>|<em>directory-path</em><br />
78 <a href="directive-dict.html#Context"
79 rel="Help"><strong>Context:</strong></a> server config, virtual
81 <a href="directive-dict.html#Status"
82 rel="Help"><strong>Status:</strong></a> Base<br />
83 <a href="directive-dict.html#Module"
84 rel="Help"><strong>Module:</strong></a> mod_alias</p>
86 <p>The Alias directive allows documents to be stored in the
87 local filesystem other than under the <a
88 href="core.html#documentroot">DocumentRoot</a>. URLs with a
89 (%-decoded) path beginning with <em>url-path</em> will be
90 mapped to local files beginning with
91 <em>directory-filename</em>.</p>
96 <code>Alias /image /ftp/pub/image</code>
99 <p>A request for http://myserver/image/foo.gif would cause the
100 server to return the file /ftp/pub/image/foo.gif.</p>
102 <p>Note that if you include a trailing / on the
103 <em>url-path</em> then the server will require a trailing / in
104 order to expand the alias. That is, if you use <code>Alias
105 /icons/ /usr/local/apache/icons/</code> then the url
106 <code>/icons</code> will not be aliased.</p>
108 <p>Note that you may need to specify additional <a
109 href="core.html#directory"><code><Directory></code></a>
110 sections which cover the <em>destination</em> of aliases.
111 Aliasing occurs before <code><Directory></code> sections
112 are checked, so only the destination of aliases are affected.
114 href="core.html#location"><code><Location></code></a>
115 sections are run through once before aliases are performed, so
116 they will apply.)</p>
118 <p>See also <a href="#scriptalias">ScriptAlias</a>.</p>
121 <h2><a id="aliasmatch" name="aliasmatch">AliasMatch</a></h2>
123 <p><a href="directive-dict.html#Syntax"
124 rel="Help"><strong>Syntax:</strong></a> AliasMatch <em>regex
125 file-path</em>|<em>directory-path</em><br />
126 <a href="directive-dict.html#Context"
127 rel="Help"><strong>Context:</strong></a> server config, virtual
129 <a href="directive-dict.html#Status"
130 rel="Help"><strong>Status:</strong></a> Base<br />
131 <a href="directive-dict.html#Module"
132 rel="Help"><strong>Module:</strong></a> mod_alias</p>
134 <p>This directive is equivalent to <a href="#alias">Alias</a>,
135 but makes use of standard regular expressions, instead of
136 simple prefix matching. The supplied regular expression is
137 matched against the URL-path, and if it matches, the server
138 will substitute any parenthesized matches into the given string
139 and use it as a filename. For example, to activate the
140 <code>/icons</code> directory, one might use:</p>
142 AliasMatch ^/icons(.*) /usr/local/apache/icons$1
149 <h2><a id="redirect" name="redirect">Redirect
152 <p><!--%plaintext <?INDEX {\tt Redirect} directive> -->
153 <a href="directive-dict.html#Syntax"
154 rel="Help"><strong>Syntax:</strong></a> Redirect
155 [<em>status</em>] <em>URL-path URL</em><br />
156 <a href="directive-dict.html#Context"
157 rel="Help"><strong>Context:</strong></a> server config, virtual
158 host, directory, .htaccess<br />
159 <a href="directive-dict.html#Override"
160 rel="Help"><strong>Override:</strong></a> FileInfo<br />
161 <a href="directive-dict.html#Status"
162 rel="Help"><strong>Status:</strong></a> Base<br />
163 <a href="directive-dict.html#Module"
164 rel="Help"><strong>Module:</strong></a> mod_alias</p>
166 <p>The Redirect directive maps an old URL into a new one. The
167 new URL is returned to the client which attempts to fetch it
168 again with the new address. <em>URL-path</em> a (%-decoded)
169 path; any requests for documents beginning with this path will
170 be returned a redirect error to a new (%-encoded) URL beginning
171 with <em>URL</em>.</p>
176 <code>Redirect /service http://foo2.bar.com/service</code>
179 <p>If the client requests http://myserver/service/foo.txt, it
180 will be told to access http://foo2.bar.com/service/foo.txt
183 <p><strong>Note:</strong> Redirect directives take precedence
184 over Alias and ScriptAlias directives, irrespective of their
185 ordering in the configuration file. Also, <em>URL-path</em>
186 must be an absolute path, not a relative path, even when used
187 with .htaccess files or inside of <Directory>
190 <p>If no <em>status</em> argument is given, the redirect will
191 be "temporary" (HTTP status 302). This indicates to the client
192 that the resource has moved temporarily. The <em>status</em>
193 argument can be used to return other HTTP status codes:</p>
198 <dd>Returns a permanent redirect status (301) indicating that
199 the resource has moved permanently.</dd>
203 <dd>Returns a temporary redirect status (302). This is the
208 <dd>Returns a "See Other" status (303) indicating that the
209 resource has been replaced.</dd>
213 <dd>Returns a "Gone" status (410) indicating that the
214 resource has been permanently removed. When this status is
215 used the <em>url</em> argument should be omitted.</dd>
218 <p>Other status codes can be returned by giving the numeric
219 status code as the value of <em>status</em>. If the status is
220 between 300 and 399, the <em>url</em> argument must be present,
221 otherwise it must be omitted. Note that the status must be
222 known to the Apache code (see the function
223 <code>send_error_response</code> in http_protocol.c).</p>
226 <h2><a id="redirectmatch"
227 name="redirectmatch">RedirectMatch</a></h2>
229 <p><a href="directive-dict.html#Syntax"
230 rel="Help"><strong>Syntax:</strong></a> RedirectMatch
231 [<em>status</em>] <em>regex URL</em><br />
232 <a href="directive-dict.html#Context"
233 rel="Help"><strong>Context:</strong></a> server config, virtual
234 host, directory, .htaccess<br />
235 <a href="directive-dict.html#Override"
236 rel="Help"><strong>Override:</strong></a> FileInfo<br />
237 <a href="directive-dict.html#Status"
238 rel="Help"><strong>Status:</strong></a> Base<br />
239 <a href="directive-dict.html#Module"
240 rel="Help"><strong>Module:</strong></a> mod_alias</p>
242 <p>This directive is equivalent to <a
243 href="#redirect">Redirect</a>, but makes use of standard
244 regular expressions, instead of simple prefix matching. The
245 supplied regular expression is matched against the URL-path,
246 and if it matches, the server will substitute any parenthesized
247 matches into the given string and use it as a filename. For
248 example, to redirect all GIF files to like-named JPEG files on
249 another server, one might use:</p>
251 RedirectMatch (.*)\.gif$ http://www.anotherserver.com$1.jpg
258 <h2><a id="redirecttemp" name="redirecttemp">RedirectTemp
261 <p><!--%plaintext <?INDEX {\tt Redirect} directive> -->
262 <a href="directive-dict.html#Syntax"
263 rel="Help"><strong>Syntax:</strong></a> RedirectTemp
264 <em>URL-path URL</em><br />
265 <a href="directive-dict.html#Context"
266 rel="Help"><strong>Context:</strong></a> server config, virtual
267 host, directory, .htaccess<br />
268 <a href="directive-dict.html#Override"
269 rel="Help"><strong>Override:</strong></a> FileInfo<br />
270 <a href="directive-dict.html#Status"
271 rel="Help"><strong>Status:</strong></a> Base<br />
272 <a href="directive-dict.html#Module"
273 rel="Help"><strong>Module:</strong></a> mod_alias</p>
275 <p>This directive makes the client know that the Redirect is
276 only temporary (status 302). Exactly equivalent to
277 <code>Redirect temp</code>.</p>
280 <h2><a id="redirectperm" name="redirectperm">RedirectPermanent
283 <p><!--%plaintext <?INDEX {\tt Redirect} directive> -->
284 <a href="directive-dict.html#Syntax"
285 rel="Help"><strong>Syntax:</strong></a> RedirectPermanent
286 <em>URL-path URL</em><br />
287 <a href="directive-dict.html#Context"
288 rel="Help"><strong>Context:</strong></a> server config, virtual
289 host, directory, .htaccess<br />
290 <a href="directive-dict.html#Override"
291 rel="Help"><strong>Override:</strong></a> FileInfo<br />
292 <a href="directive-dict.html#Status"
293 rel="Help"><strong>Status:</strong></a> Base<br />
294 <a href="directive-dict.html#Module"
295 rel="Help"><strong>Module:</strong></a> mod_alias</p>
297 <p>This directive makes the client know that the Redirect is
298 permanent (status 301). Exactly equivalent to <code>Redirect
299 permanent</code>.</p>
302 <h2><a id="scriptalias" name="scriptalias">ScriptAlias
306 <!--%plaintext <?INDEX {\tt ScriptAlias} directive> -->
307 <a href="directive-dict.html#Syntax"
308 rel="Help"><strong>Syntax:</strong></a> ScriptAlias
309 <em>URL-path file-path</em>|<em>directory-path</em><br />
310 <a href="directive-dict.html#Context"
311 rel="Help"><strong>Context:</strong></a> server config, virtual
313 <a href="directive-dict.html#Status"
314 rel="Help"><strong>Status:</strong></a> Base<br />
315 <a href="directive-dict.html#Module"
316 rel="Help"><strong>Module:</strong></a> mod_alias</p>
318 <p>The ScriptAlias directive has the same behavior as the <a
319 href="#alias">Alias</a> directive, except that in addition it
320 marks the target directory as containing CGI scripts. URLs with
321 a (%-decoded) path beginning with <em>URL-path</em> will be
322 mapped to scripts beginning with the second argument which is a
323 full pathname in the local filesystem.</p>
328 <code>ScriptAlias /cgi-bin/ /web/cgi-bin/</code>
331 <p>A request for http://myserver/cgi-bin/foo would cause the
332 server to run the script /web/cgi-bin/foo.</p>
335 <h2><a id="scriptaliasmatch"
336 name="scriptaliasmatch">ScriptAliasMatch</a></h2>
338 <p><a href="directive-dict.html#Syntax"
339 rel="Help"><strong>Syntax:</strong></a> ScriptAliasMatch
340 <em>regex file-path</em>|<em>directory-path</em><br />
341 <a href="directive-dict.html#Context"
342 rel="Help"><strong>Context:</strong></a> server config, virtual
344 <a href="directive-dict.html#Status"
345 rel="Help"><strong>Status:</strong></a> Base<br />
346 <a href="directive-dict.html#Module"
347 rel="Help"><strong>Module:</strong></a> mod_alias</p>
349 <p>This directive is equivalent to <a
350 href="#scriptalias">ScriptAlias</a>, but makes use of standard
351 regular expressions, instead of simple prefix matching. The
352 supplied regular expression is matched against the URL-path,
353 and if it matches, the server will substitute any parenthesized
354 matches into the given string and use it as a filename. For
355 example, to activate the standard <code>/cgi-bin</code>, one
358 ScriptAliasMatch ^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
362 <!--#include virtual="footer.html" -->