]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_alias.html.en
a few new translations and up-to-date patches
[apache] / docs / manual / mod / mod_alias.html.en
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
7       -->
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>
13 <body>
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.1</p>
17 <img alt="" src="../images/feather.gif" /></div>
18 <div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="../images/left.gif" /></a></div>
19 <div id="path">
20 <a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs-project/">Documentation</a> &gt; <a href="../">Version 2.1</a> &gt; <a href="./">Modules</a></div>
21 <div id="page-content">
22 <div id="preamble"><h1>Apache Module mod_alias</h1>
23 <div class="toplang">
24 <p><span>Available Languages: </span><a href="../en/mod/mod_alias.html" title="English">&nbsp;en&nbsp;</a> |
25 <a href="../ja/mod/mod_alias.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
26 <a href="../ko/mod/mod_alias.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a></p>
27 </div>
28 <table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Provides for mapping different parts of the host
29     filesystem in the document tree and for URL redirection</td></tr>
30 <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Base</td></tr>
31 <tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>alias_module</td></tr>
32 <tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>mod_alias.c</td></tr></table>
33 <h3>Summary</h3>
34
35     <p>The directives contained in this module allow for manipulation
36     and control of URLs as requests arrive at the server. The
37     <code class="directive"><a href="#alias">Alias</a></code> and <code class="directive"><a href="#scriptalias">ScriptAlias</a></code> directives are used to
38     map between URLs and filesystem paths.  This allows for content
39     which is not directly under the <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code> served as part of the web
40     document tree. The <code class="directive"><a href="#scriptalias">ScriptAlias</a></code> directive has the
41     additional effect of marking the target directory as containing
42     only CGI scripts.</p>
43
44     <p>The <code class="directive"><a href="#redirect">Redirect</a></code>
45     directives are used to instruct clients to make a new request with
46     a different URL. They are often used when a resource has moved to
47     a new location.</p>
48
49     <p><code class="module"><a href="../mod/mod_alias.html">mod_alias</a></code> is designed to handle simple URL
50     manipulation tasks.  For more complicated tasks such as
51     manipulating the query string, use the tools provided by
52     <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>.</p>
53
54 </div>
55 <div id="quickview"><h3 class="directives">Directives</h3>
56 <ul id="toc">
57 <li><img alt="" src="../images/down.gif" /> <a href="#alias">Alias</a></li>
58 <li><img alt="" src="../images/down.gif" /> <a href="#aliasmatch">AliasMatch</a></li>
59 <li><img alt="" src="../images/down.gif" /> <a href="#redirect">Redirect</a></li>
60 <li><img alt="" src="../images/down.gif" /> <a href="#redirectmatch">RedirectMatch</a></li>
61 <li><img alt="" src="../images/down.gif" /> <a href="#redirectpermanent">RedirectPermanent</a></li>
62 <li><img alt="" src="../images/down.gif" /> <a href="#redirecttemp">RedirectTemp</a></li>
63 <li><img alt="" src="../images/down.gif" /> <a href="#scriptalias">ScriptAlias</a></li>
64 <li><img alt="" src="../images/down.gif" /> <a href="#scriptaliasmatch">ScriptAliasMatch</a></li>
65 </ul>
66 <h3>Topics</h3>
67 <ul id="topics">
68 <li><img alt="" src="../images/down.gif" /> <a href="#order">Order of Processing</a></li>
69 </ul><h3>See also</h3>
70 <ul class="seealso">
71 <li><code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code></li>
72 <li><a href="../urlmapping.html">Mapping URLs to the filesystem</a></li>
73 </ul></div>
74 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
75 <div class="section">
76 <h2><a name="order" id="order">Order of Processing</a></h2>
77
78 <p>Aliases and Redirects occuring in different contexts are processed
79 like other directives according to standard <a href="../sections.html#mergin">merging rules</a>.  But when multiple
80 Aliases or Redirects occur in the same context (for example, in the
81 same <code class="directive"><a href="../mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code>
82 section) they are processed in a particular order.</p>
83
84 <p>First, all Redirects are processed before Aliases are processed,
85 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
86 applied.  Second, the Aliases and Redirects are processed in the order
87 they appear in the configuration files, with the first match taking
88 precedence.</p>
89
90 <p>For this reason, when two or more of these directives apply to the
91 same sub-path, you must list the most specific path first in order for
92 all the directives to have an effect.  For example, the following
93 configuration will work as expected:</p>
94
95 <div class="example"><p><code>
96 Alias /foo/bar /baz<br />
97 Alias /foo /gaq
98 </code></p></div>
99
100 <p>But if the above two directives were reversed in order, the
101 <code>/foo</code> <code class="directive"><a href="#alias">Alias</a></code>
102 would always match before the <code>/foo/bar</code> <code class="directive"><a href="#alias">Alias</a></code>, so the latter directive would be
103 ignored.</p>
104
105 </div>
106 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
107 <div class="directive-section"><h2><a name="Alias" id="Alias">Alias</a> <a name="alias" id="alias">Directive</a></h2>
108 <table class="directive">
109 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps URLs to filesystem locations</td></tr>
110 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>Alias <var>URL-path</var>
111 <var>file-path</var>|<var>directory-path</var></code></td></tr>
112 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
113 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
114 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
115 </table>
116
117     <p>The <code class="directive">Alias</code> directive allows documents to
118     be stored in the local filesystem other than under the 
119     <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code>. URLs with a
120     (%-decoded) path beginning with <var>url-path</var> will be mapped
121     to local files beginning with <var>directory-path</var>.</p>
122
123     <div class="example"><h3>Example:</h3><p><code>
124       Alias /image /ftp/pub/image
125     </code></p></div>
126
127     <p>A request for http://myserver/image/foo.gif would cause the
128     server to return the file /ftp/pub/image/foo.gif.</p>
129
130     <p>Note that if you include a trailing / on the
131     <var>url-path</var> then the server will require a trailing / in
132     order to expand the alias. That is, if you use <code>Alias
133     /icons/ /usr/local/apache/icons/</code> then the url
134     <code>/icons</code> will not be aliased.</p>
135
136     <p>Note that you may need to specify additional <code class="directive"><a href="../mod/core.html#directory">&lt;Directory&gt;</a></code> sections which
137     cover the <em>destination</em> of aliases.  Aliasing occurs before
138     <code class="directive"><a href="../mod/core.html#directory">&lt;Directory&gt;</a></code> sections
139     are checked, so only the destination of aliases are affected.
140     (Note however <code class="directive"><a href="../mod/core.html#location">&lt;Location&gt;</a></code>
141     sections are run through once before aliases are performed, so
142     they will apply.)</p>
143
144     <p>In particular, if you are creating an <code>Alias</code> to a
145     directory outside of your <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code>, you may need to explicitly
146     permit access to the target directory.</p>
147
148     <div class="example"><h3>Example:</h3><p><code>
149         Alias /image /ftp/pub/image<br />
150         &lt;Directory /ftp/pub/image&gt;<br />
151         <span class="indent">
152             Order allow,deny<br />
153             Allow from all<br />
154         </span>
155         &lt;/Directory&gt;
156     </code></p></div>
157
158
159 </div>
160 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
161 <div class="directive-section"><h2><a name="AliasMatch" id="AliasMatch">AliasMatch</a> <a name="aliasmatch" id="aliasmatch">Directive</a></h2>
162 <table class="directive">
163 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps URLs to filesystem locations using regular 
164 expressions</td></tr>
165 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>AliasMatch <var>regex</var>
166 <var>file-path</var>|<var>directory-path</var></code></td></tr>
167 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
168 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
169 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
170 </table>
171     <p>This directive is equivalent to <code class="directive"><a href="#alias">Alias</a></code>, but makes use of standard
172     regular expressions, instead of simple prefix matching. The
173     supplied regular expression is matched against the URL-path, and
174     if it matches, the server will substitute any parenthesized
175     matches into the given string and use it as a filename. For
176     example, to activate the <code>/icons</code> directory, one might
177     use:</p>
178
179     <div class="example"><p><code>
180       AliasMatch ^/icons(.*) /usr/local/apache/icons$1
181     </code></p></div>
182
183 </div>
184 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
185 <div class="directive-section"><h2><a name="Redirect" id="Redirect">Redirect</a> <a name="redirect" id="redirect">Directive</a></h2>
186 <table class="directive">
187 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sends an external redirect asking the client to fetch
188 a different URL</td></tr>
189 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>Redirect [<var>status</var>] <var>URL-path</var>
190 <var>URL</var></code></td></tr>
191 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
192 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
193 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
194 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
195 </table>
196     <p>The Redirect directive maps an old URL into a new one. The
197     new URL is returned to the client which attempts to fetch it
198     again with the new address. <var>URL-path</var> a (%-decoded)
199     path; any requests for documents beginning with this path will
200     be returned a redirect error to a new (%-encoded) URL beginning
201     with <var>URL</var>.</p>
202
203     <div class="example"><h3>Example:</h3><p><code>
204       Redirect /service http://foo2.bar.com/service
205     </code></p></div>
206
207     <p>If the client requests http://myserver/service/foo.txt, it
208     will be told to access http://foo2.bar.com/service/foo.txt
209     instead.</p>
210
211 <div class="note"><h3>Note</h3> <p>Redirect directives take precedence over
212 Alias and ScriptAlias directives, irrespective of their ordering in
213 the configuration file. Also, <var>URL-path</var> must be a fully
214 qualified URL, not a relative path, even when used with .htaccess files or
215 inside of <code class="directive"><a href="../mod/core.html#directory">&lt;Directory&gt;</a></code>
216 sections.</p></div>
217
218     <p>If no <var>status</var> argument is given, the redirect will
219     be "temporary" (HTTP status 302). This indicates to the client
220     that the resource has moved temporarily. The <var>status</var>
221     argument can be used to return other HTTP status codes:</p>
222
223     <dl>
224       <dt>permanent</dt>
225
226       <dd>Returns a permanent redirect status (301) indicating that
227       the resource has moved permanently.</dd>
228
229       <dt>temp</dt>
230
231       <dd>Returns a temporary redirect status (302). This is the
232       default.</dd>
233
234       <dt>seeother</dt>
235
236       <dd>Returns a "See Other" status (303) indicating that the
237       resource has been replaced.</dd>
238
239       <dt>gone</dt>
240
241       <dd>Returns a "Gone" status (410) indicating that the
242       resource has been permanently removed. When this status is
243       used the <var>URL</var> argument should be omitted.</dd>
244     </dl>
245
246     <p>Other status codes can be returned by giving the numeric
247     status code as the value of <var>status</var>. If the status is
248     between 300 and 399, the <var>URL</var> argument must be present,
249     otherwise it must be omitted. Note that the status must be
250     known to the Apache code (see the function
251     <code>send_error_response</code> in http_protocol.c).</p>
252
253     <div class="example"><h3>Example:</h3><p><code>
254       Redirect permanent /one http://example.com/two<br />
255       Redirect 303 /three http://example.com/other
256     </code></p></div>
257
258
259 </div>
260 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
261 <div class="directive-section"><h2><a name="RedirectMatch" id="RedirectMatch">RedirectMatch</a> <a name="redirectmatch" id="redirectmatch">Directive</a></h2>
262 <table class="directive">
263 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sends an external redirect based on a regular expression match 
264 of the current URL</td></tr>
265 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RedirectMatch [<var>status</var>] <var>regex</var>
266 <var>URL</var></code></td></tr>
267 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
268 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
269 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
270 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
271 </table>
272     <p>This directive is equivalent to <code class="directive"><a href="#redirect">Redirect</a></code>, but makes use of standard
273     regular expressions, instead of simple prefix matching. The
274     supplied regular expression is matched against the URL-path, and
275     if it matches, the server will substitute any parenthesized
276     matches into the given string and use it as a filename. For
277     example, to redirect all GIF files to like-named JPEG files on
278     another server, one might use:</p>
279
280     <div class="example"><p><code>
281       RedirectMatch (.*)\.gif$ http://www.anotherserver.com$1.jpg
282     </code></p></div>
283
284 </div>
285 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
286 <div class="directive-section"><h2><a name="RedirectPermanent" id="RedirectPermanent">RedirectPermanent</a> <a name="redirectpermanent" id="redirectpermanent">Directive</a></h2>
287 <table class="directive">
288 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sends an external permanent redirect asking the client to fetch
289 a different URL</td></tr>
290 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RedirectPermanent <var>URL-path</var> <var>URL</var></code></td></tr>
291 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
292 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
293 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
294 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
295 </table>
296     <p>This directive makes the client know that the Redirect is
297     permanent (status 301). Exactly equivalent to <code>Redirect
298     permanent</code>.</p>
299
300 </div>
301 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
302 <div class="directive-section"><h2><a name="RedirectTemp" id="RedirectTemp">RedirectTemp</a> <a name="redirecttemp" id="redirecttemp">Directive</a></h2>
303 <table class="directive">
304 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sends an external temporary redirect asking the client to fetch
305 a different URL</td></tr>
306 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RedirectTemp <var>URL-path</var> <var>URL</var></code></td></tr>
307 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
308 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
309 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
310 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
311 </table>
312     <p>This directive makes the client know that the Redirect is
313     only temporary (status 302). Exactly equivalent to
314     <code>Redirect temp</code>.</p>
315
316 </div>
317 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
318 <div class="directive-section"><h2><a name="ScriptAlias" id="ScriptAlias">ScriptAlias</a> <a name="scriptalias" id="scriptalias">Directive</a></h2>
319 <table class="directive">
320 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps a URL to a filesystem location and designates the
321 target as a CGI script</td></tr>
322 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ScriptAlias <var>URL-path</var>
323 <var>file-path</var>|<var>directory-path</var></code></td></tr>
324 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
325 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
326 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
327 </table>
328     <p>The <code class="directive">ScriptAlias</code> directive has the same
329     behavior as the <code class="directive"><a href="#alias">Alias</a></code>
330     directive, except that in addition it marks the target directory
331     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
332     (%-decoded) path beginning with <var>URL-path</var> will be mapped
333     to scripts beginning with the second argument which is a full
334     pathname in the local filesystem.</p>
335
336     <div class="example"><h3>Example:</h3><p><code>
337       ScriptAlias /cgi-bin/ /web/cgi-bin/
338     </code></p></div>
339
340     <p>A request for <code>http://myserver/cgi-bin/foo</code> would cause the
341     server to run the script <code>/web/cgi-bin/foo</code>.</p>
342
343 </div>
344 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
345 <div class="directive-section"><h2><a name="ScriptAliasMatch" id="ScriptAliasMatch">ScriptAliasMatch</a> <a name="scriptaliasmatch" id="scriptaliasmatch">Directive</a></h2>
346 <table class="directive">
347 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps a URL to a filesystem location using a regular expression
348 and designates the target as a CGI script</td></tr>
349 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ScriptAliasMatch <var>regex</var>
350 <var>file-path</var>|<var>directory-path</var></code></td></tr>
351 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
352 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
353 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
354 </table>
355     <p>This directive is equivalent to <code class="directive"><a href="#scriptalias">ScriptAlias</a></code>, but makes use of standard
356     regular expressions, instead of simple prefix matching. The
357     supplied regular expression is matched against the URL-path,
358     and if it matches, the server will substitute any parenthesized
359     matches into the given string and use it as a filename. For
360     example, to activate the standard <code>/cgi-bin</code>, one
361     might use:</p>
362
363     <div class="example"><p><code>
364       ScriptAliasMatch ^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
365     </code></p></div>
366
367 </div>
368 </div>
369 <div class="bottomlang">
370 <p><span>Available Languages: </span><a href="../en/mod/mod_alias.html" title="English">&nbsp;en&nbsp;</a> |
371 <a href="../ja/mod/mod_alias.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
372 <a href="../ko/mod/mod_alias.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a></p>
373 </div><div id="footer">
374 <p class="apache">Copyright 1999-2004 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>
375 <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>
376 </body></html>