1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
4 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5 This file is generated from xml source: DO NOT EDIT
6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
8 <title>mod_alias - Apache HTTP Server</title>
9 <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
10 <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
11 <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
12 <link href="../images/favicon.ico" rel="shortcut icon" /></head>
14 <div id="page-header">
15 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
16 <p class="apache">Apache HTTP Server Version 2.0</p>
17 <img alt="" src="../images/feather.gif" /></div>
18 <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div>
20 <a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.0</a> > <a href="./">Modules</a></div>
21 <div id="page-content">
22 <div id="preamble"><h1>Apache Module mod_alias</h1>
24 <p><span>Available Languages: </span><a href="../en/mod/mod_alias.html" title="English"> en </a> |
25 <a href="../ja/mod/mod_alias.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
26 <a href="../ko/mod/mod_alias.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> |
27 <a href="../tr/mod/mod_alias.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p>
29 <table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Provides for mapping different parts of the host
30 filesystem in the document tree and for URL redirection</td></tr>
31 <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Base</td></tr>
32 <tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>alias_module</td></tr>
33 <tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>mod_alias.c</td></tr></table>
36 <p>The directives contained in this module allow for manipulation
37 and control of URLs as requests arrive at the server. The
38 <code class="directive"><a href="#alias">Alias</a></code> and <code class="directive"><a href="#scriptalias">ScriptAlias</a></code> directives are used to
39 map between URLs and filesystem paths. This allows for content
40 which is not directly under the <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code> served as part of the web
41 document tree. The <code class="directive"><a href="#scriptalias">ScriptAlias</a></code> directive has the
42 additional effect of marking the target directory as containing
45 <p>The <code class="directive"><a href="#redirect">Redirect</a></code>
46 directives are used to instruct clients to make a new request with
47 a different URL. They are often used when a resource has moved to
50 <p><code class="module"><a href="../mod/mod_alias.html">mod_alias</a></code> is designed to handle simple URL
51 manipulation tasks. For more complicated tasks such as
52 manipulating the query string, use the tools provided by
53 <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>.</p>
56 <div id="quickview"><h3 class="directives">Directives</h3>
58 <li><img alt="" src="../images/down.gif" /> <a href="#alias">Alias</a></li>
59 <li><img alt="" src="../images/down.gif" /> <a href="#aliasmatch">AliasMatch</a></li>
60 <li><img alt="" src="../images/down.gif" /> <a href="#redirect">Redirect</a></li>
61 <li><img alt="" src="../images/down.gif" /> <a href="#redirectmatch">RedirectMatch</a></li>
62 <li><img alt="" src="../images/down.gif" /> <a href="#redirectpermanent">RedirectPermanent</a></li>
63 <li><img alt="" src="../images/down.gif" /> <a href="#redirecttemp">RedirectTemp</a></li>
64 <li><img alt="" src="../images/down.gif" /> <a href="#scriptalias">ScriptAlias</a></li>
65 <li><img alt="" src="../images/down.gif" /> <a href="#scriptaliasmatch">ScriptAliasMatch</a></li>
69 <li><img alt="" src="../images/down.gif" /> <a href="#order">Order of Processing</a></li>
70 </ul><h3>See also</h3>
72 <li><code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code></li>
73 <li><a href="../urlmapping.html">Mapping URLs to the filesystem</a></li>
75 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
77 <h2><a name="order" id="order">Order of Processing</a></h2>
79 <p>Aliases and Redirects occuring in different contexts are processed
80 like other directives according to standard <a href="../sections.html#mergin">merging rules</a>. But when multiple
81 Aliases or Redirects occur in the same context (for example, in the
82 same <code class="directive"><a href="../mod/core.html#virtualhost"><VirtualHost></a></code>
83 section) they are processed in a particular order.</p>
85 <p>First, all Redirects are processed before Aliases are processed,
86 and therefore a request that matches a <code class="directive"><a href="#redirect">Redirect</a></code> or <code class="directive"><a href="#redirectmatch">RedirectMatch</a></code> will never have Aliases
87 applied. Second, the Aliases and Redirects are processed in the order
88 they appear in the configuration files, with the first match taking
91 <p>For this reason, when two or more of these directives apply to the
92 same sub-path, you must list the most specific path first in order for
93 all the directives to have an effect. For example, the following
94 configuration will work as expected:</p>
96 <div class="example"><p><code>
97 Alias /foo/bar /baz<br />
101 <p>But if the above two directives were reversed in order, the
102 <code>/foo</code> <code class="directive"><a href="#alias">Alias</a></code>
103 would always match before the <code>/foo/bar</code> <code class="directive"><a href="#alias">Alias</a></code>, so the latter directive would be
107 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
108 <div class="directive-section"><h2><a name="Alias" id="Alias">Alias</a> <a name="alias" id="alias">Directive</a></h2>
109 <table class="directive">
110 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps URLs to filesystem locations</td></tr>
111 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>Alias <var>URL-path</var>
112 <var>file-path</var>|<var>directory-path</var></code></td></tr>
113 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
114 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
115 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
118 <p>The <code class="directive">Alias</code> directive allows documents to
119 be stored in the local filesystem other than under the
120 <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code>. URLs with a
121 (%-decoded) path beginning with <var>url-path</var> will be mapped
122 to local files beginning with <var>directory-path</var>. The
123 <var>url-path</var> is case-sensitive, even on case-insenitive
126 <div class="example"><h3>Example:</h3><p><code>
127 Alias /image /ftp/pub/image
130 <p>A request for <code>http://myserver/image/foo.gif</code> would cause
131 the server to return the file <code>/ftp/pub/image/foo.gif</code>.</p>
133 <p>Note that if you include a trailing / on the
134 <var>url-path</var> then the server will require a trailing / in
135 order to expand the alias. That is, if you use</p>
137 <dl><dd><code>Alias /icons/ /usr/local/apache/icons/</code></dd></dl>
139 <p>then the url <code>/icons</code> will not be aliased.</p>
141 <p>Note that you may need to specify additional <code class="directive"><a href="../mod/core.html#directory"><Directory></a></code> sections which
142 cover the <em>destination</em> of aliases. Aliasing occurs before
143 <code class="directive"><a href="../mod/core.html#directory"><Directory></a></code> sections
144 are checked, so only the destination of aliases are affected.
145 (Note however <code class="directive"><a href="../mod/core.html#location"><Location></a></code>
146 sections are run through once before aliases are performed, so
147 they will apply.)</p>
149 <p>In particular, if you are creating an <code>Alias</code> to a
150 directory outside of your <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code>, you may need to explicitly
151 permit access to the target directory.</p>
153 <div class="example"><h3>Example:</h3><p><code>
154 Alias /image /ftp/pub/image<br />
155 <Directory /ftp/pub/image><br />
156 <span class="indent">
157 Order allow,deny<br />
165 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
166 <div class="directive-section"><h2><a name="AliasMatch" id="AliasMatch">AliasMatch</a> <a name="aliasmatch" id="aliasmatch">Directive</a></h2>
167 <table class="directive">
168 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps URLs to filesystem locations using regular
169 expressions</td></tr>
170 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>AliasMatch <var>regex</var>
171 <var>file-path</var>|<var>directory-path</var></code></td></tr>
172 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
173 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
174 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
176 <p>This directive is equivalent to <code class="directive"><a href="#alias">Alias</a></code>, but makes use of standard
177 regular expressions, instead of simple prefix matching. The
178 supplied regular expression is matched against the URL-path, and
179 if it matches, the server will substitute any parenthesized
180 matches into the given string and use it as a filename. For
181 example, to activate the <code>/icons</code> directory, one might
184 <div class="example"><p><code>
185 AliasMatch ^/icons(.*) /usr/local/apache/icons$1
188 <p>It is also possible to construct an alias with case-insensitive
189 matching of the url-path:</p>
191 <div class="example"><p><code>
192 AliasMatch (?i)^/image(.*) /ftp/pub/image$1
197 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
198 <div class="directive-section"><h2><a name="Redirect" id="Redirect">Redirect</a> <a name="redirect" id="redirect">Directive</a></h2>
199 <table class="directive">
200 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sends an external redirect asking the client to fetch
201 a different URL</td></tr>
202 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>Redirect [<var>status</var>] <var>URL-path</var>
203 <var>URL</var></code></td></tr>
204 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
205 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
206 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
207 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
209 <p>The Redirect directive maps an old URL into a new one by asking
210 the client to refetch the resource at the new location.</p>
212 <p>The old <em>URL-path</em> is a case-sensitive (%-decoded) path
213 beginning with a slash. A relative path is not allowed. The new
214 <em>URL</em> should be an absolute URL beginning with a scheme and
217 <div class="example"><h3>Example:</h3><p><code>
218 Redirect /service http://foo2.bar.com/service
221 <p>If the client requests <code>http://myserver/service/foo.txt</code>, it
222 will be told to access <code>http://foo2.bar.com/service/foo.txt</code>
225 <div class="note"><h3>Note</h3>
226 <p>Redirect directives take precedence over
227 Alias and ScriptAlias directives, irrespective of their ordering in
228 the configuration file. Also, <var>URL-path</var> must be a fully
229 qualified URL, not a relative path, even when used with .htaccess files or
230 inside of <code class="directive"><a href="../mod/core.html#directory"><Directory></a></code>
233 <p>If no <var>status</var> argument is given, the redirect will
234 be "temporary" (HTTP status 302). This indicates to the client
235 that the resource has moved temporarily. The <var>status</var>
236 argument can be used to return other HTTP status codes:</p>
241 <dd>Returns a permanent redirect status (301) indicating that
242 the resource has moved permanently.</dd>
246 <dd>Returns a temporary redirect status (302). This is the
251 <dd>Returns a "See Other" status (303) indicating that the
252 resource has been replaced.</dd>
256 <dd>Returns a "Gone" status (410) indicating that the
257 resource has been permanently removed. When this status is
258 used the <var>URL</var> argument should be omitted.</dd>
261 <p>Other status codes can be returned by giving the numeric
262 status code as the value of <var>status</var>. If the status is
263 between 300 and 399, the <var>URL</var> argument must be present,
264 otherwise it must be omitted. Note that the status must be
265 known to the Apache code (see the function
266 <code>send_error_response</code> in http_protocol.c).</p>
268 <div class="example"><h3>Example:</h3><p><code>
269 Redirect permanent /one http://example.com/two<br />
270 Redirect 303 /three http://example.com/other
275 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
276 <div class="directive-section"><h2><a name="RedirectMatch" id="RedirectMatch">RedirectMatch</a> <a name="redirectmatch" id="redirectmatch">Directive</a></h2>
277 <table class="directive">
278 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sends an external redirect based on a regular expression match
279 of the current URL</td></tr>
280 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RedirectMatch [<var>status</var>] <var>regex</var>
281 <var>URL</var></code></td></tr>
282 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
283 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
284 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
285 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
287 <p>This directive is equivalent to <code class="directive"><a href="#redirect">Redirect</a></code>, but makes use of standard
288 regular expressions, instead of simple prefix matching. The
289 supplied regular expression is matched against the URL-path, and
290 if it matches, the server will substitute any parenthesized
291 matches into the given string and use it as a filename. For
292 example, to redirect all GIF files to like-named JPEG files on
293 another server, one might use:</p>
295 <div class="example"><p><code>
296 RedirectMatch (.*)\.gif$ http://www.anotherserver.com$1.jpg
300 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
301 <div class="directive-section"><h2><a name="RedirectPermanent" id="RedirectPermanent">RedirectPermanent</a> <a name="redirectpermanent" id="redirectpermanent">Directive</a></h2>
302 <table class="directive">
303 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sends an external permanent redirect asking the client to fetch
304 a different URL</td></tr>
305 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RedirectPermanent <var>URL-path</var> <var>URL</var></code></td></tr>
306 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
307 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
308 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
309 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
311 <p>This directive makes the client know that the Redirect is
312 permanent (status 301). Exactly equivalent to <code>Redirect
313 permanent</code>.</p>
316 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
317 <div class="directive-section"><h2><a name="RedirectTemp" id="RedirectTemp">RedirectTemp</a> <a name="redirecttemp" id="redirecttemp">Directive</a></h2>
318 <table class="directive">
319 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sends an external temporary redirect asking the client to fetch
320 a different URL</td></tr>
321 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RedirectTemp <var>URL-path</var> <var>URL</var></code></td></tr>
322 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
323 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
324 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
325 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
327 <p>This directive makes the client know that the Redirect is
328 only temporary (status 302). Exactly equivalent to
329 <code>Redirect temp</code>.</p>
332 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
333 <div class="directive-section"><h2><a name="ScriptAlias" id="ScriptAlias">ScriptAlias</a> <a name="scriptalias" id="scriptalias">Directive</a></h2>
334 <table class="directive">
335 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps a URL to a filesystem location and designates the
336 target as a CGI script</td></tr>
337 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ScriptAlias <var>URL-path</var>
338 <var>file-path</var>|<var>directory-path</var></code></td></tr>
339 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
340 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
341 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
343 <p>The <code class="directive">ScriptAlias</code> directive has the same
344 behavior as the <code class="directive"><a href="#alias">Alias</a></code>
345 directive, except that in addition it marks the target directory
346 as containing CGI scripts that will be processed by <code class="module"><a href="../mod/mod_cgi.html">mod_cgi</a></code>'s cgi-script handler. URLs with a case-sensitive
347 (%-decoded) path beginning with <var>URL-path</var> will be mapped
348 to scripts beginning with the second argument, which is a full
349 pathname in the local filesystem.</p>
351 <div class="example"><h3>Example:</h3><p><code>
352 ScriptAlias /cgi-bin/ /web/cgi-bin/
355 <p>A request for <code>http://myserver/cgi-bin/foo</code> would cause the
356 server to run the script <code>/web/cgi-bin/foo</code>. This configuration
357 is essentially equivalent to:</p>
358 <div class="example"><p><code>
359 Alias /cgi-bin/ /web/cgi-bin/<br />
360 <Location /cgi-bin ><br />
361 <span class="indent">
362 SetHandler cgi-script<br />
363 Options +ExecCGI<br />
368 <div class="warning">It is safer to avoid placing CGI scripts under the
369 <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code> in order to
370 avoid accidentally revealing their source code if the
371 configuration is ever changed. The
372 <code class="directive">ScriptAlias</code> makes this easy by mapping a
373 URL and designating CGI scripts at the same time. If you do
374 choose to place your CGI scripts in a directory already
375 accessible from the web, do not use
376 <code class="directive">ScriptAlias</code>. Instead, use <code class="directive"><a href="../mod/core.html#directory"><Directory></a></code>, <code class="directive"><a href="../mod/core.html#sethandler">SetHandler</a></code>, and <code class="directive"><a href="../mod/core.html#options">Options</a></code> as in:
377 <div class="example"><p><code>
378 <Directory /usr/local/apache2/htdocs/cgi-bin ><br />
379 <span class="indent">
380 SetHandler cgi-script<br />
381 Options ExecCGI<br />
385 This is necessary since multiple <var>URL-paths</var> can map
386 to the same filesystem location, potentially bypassing the
387 <code class="directive">ScriptAlias</code> and revealing the source code
388 of the CGI scripts if they are not restricted by a
389 <code class="directive"><a href="../mod/core.html#directory">Directory</a></code> section.</div>
394 <li><a href="../howto/cgi.html">CGI Tutorial</a></li>
397 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
398 <div class="directive-section"><h2><a name="ScriptAliasMatch" id="ScriptAliasMatch">ScriptAliasMatch</a> <a name="scriptaliasmatch" id="scriptaliasmatch">Directive</a></h2>
399 <table class="directive">
400 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps a URL to a filesystem location using a regular expression
401 and designates the target as a CGI script</td></tr>
402 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ScriptAliasMatch <var>regex</var>
403 <var>file-path</var>|<var>directory-path</var></code></td></tr>
404 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
405 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
406 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
408 <p>This directive is equivalent to <code class="directive"><a href="#scriptalias">ScriptAlias</a></code>, but makes use of standard
409 regular expressions, instead of simple prefix matching. The
410 supplied regular expression is matched against the URL-path,
411 and if it matches, the server will substitute any parenthesized
412 matches into the given string and use it as a filename. For
413 example, to activate the standard <code>/cgi-bin</code>, one
416 <div class="example"><p><code>
417 ScriptAliasMatch ^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
422 <div class="bottomlang">
423 <p><span>Available Languages: </span><a href="../en/mod/mod_alias.html" title="English"> en </a> |
424 <a href="../ja/mod/mod_alias.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
425 <a href="../ko/mod/mod_alias.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> |
426 <a href="../tr/mod/mod_alias.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p>
427 </div><div id="footer">
428 <p class="apache">Copyright 2009 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
429 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div>