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.2</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.2</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></p>
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>
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
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
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>
55
<div id="quickview"><h3 class="directives">Directives</h3>
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>
68
<li><img alt="" src="../images/down.gif" /> <a href="#order">Order of Processing</a></li>
69
</ul><h3>See also</h3>
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>
74
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
76
<h2><a name="order" id="order">Order of Processing</a></h2>
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"><VirtualHost></a></code>
82
section) they are processed in a particular order.</p>
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
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>
95
<div class="example"><p><code>
96
Alias /foo/bar /baz<br />
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
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>
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>
123
<div class="example"><h3>Example:</h3><p><code>
124
Alias /image /ftp/pub/image
127
<p>A request for http://myserver/image/foo.gif would cause the
128
server to return the file /ftp/pub/image/foo.gif. Only complete
129
path segments are matched, so the above alias would not match a
130
request for http://myserver/imagefoo.gif. For more complex
131
matching using regular expressions, see the <code class="directive"><a href="#aliasmatch">AliasMatch</a></code> directive.</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 <code>Alias
136
/icons/ /usr/local/apache/icons/</code> then the url
137
<code>/icons</code> will not be aliased.</p>
139
<p>Note that you may need to specify additional <code class="directive"><a href="../mod/core.html#directory"><Directory></a></code> sections which
140
cover the <em>destination</em> of aliases. Aliasing occurs before
141
<code class="directive"><a href="../mod/core.html#directory"><Directory></a></code> sections
142
are checked, so only the destination of aliases are affected.
143
(Note however <code class="directive"><a href="../mod/core.html#location"><Location></a></code>
144
sections are run through once before aliases are performed, so
145
they will apply.)</p>
147
<p>In particular, if you are creating an <code>Alias</code> to a
148
directory outside of your <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code>, you may need to explicitly
149
permit access to the target directory.</p>
151
<div class="example"><h3>Example:</h3><p><code>
152
Alias /image /ftp/pub/image<br />
153
<Directory /ftp/pub/image><br />
154
<span class="indent">
155
Order allow,deny<br />
163
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
164
<div class="directive-section"><h2><a name="AliasMatch" id="AliasMatch">AliasMatch</a> <a name="aliasmatch" id="aliasmatch">Directive</a></h2>
165
<table class="directive">
166
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps URLs to filesystem locations using regular
167
expressions</td></tr>
168
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>AliasMatch <var>regex</var>
169
<var>file-path</var>|<var>directory-path</var></code></td></tr>
170
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
171
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
172
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
174
<p>This directive is equivalent to <code class="directive"><a href="#alias">Alias</a></code>, but makes use of
175
<a class="glossarylink" href="../glossary.html#regex" title="see glossary">regular expressions</a>,
176
instead of simple prefix matching. The
177
supplied regular expression is matched against the URL-path, and
178
if it matches, the server will substitute any parenthesized
179
matches into the given string and use it as a filename. For
180
example, to activate the <code>/icons</code> directory, one might
183
<div class="example"><p><code>
184
AliasMatch ^/icons(.*) /usr/local/apache/icons$1
188
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
189
<div class="directive-section"><h2><a name="Redirect" id="Redirect">Redirect</a> <a name="redirect" id="redirect">Directive</a></h2>
190
<table class="directive">
191
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sends an external redirect asking the client to fetch
192
a different URL</td></tr>
193
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>Redirect [<var>status</var>] <var>URL-path</var>
194
<var>URL</var></code></td></tr>
195
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
196
<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
197
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
198
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
200
<p>The Redirect directive maps an old URL into a new one by asking
201
the client to refetch the resource at the new location.</p>
203
<p>The old <em>URL-path</em> is a (%-decoded) path beginning with
204
a slash. A relative path is not allowed. The new <em>URL</em>
205
should be an absolute URL beginning with a scheme and hostname,
206
but a URL-path beginning with a slash may also be used, in which
207
case the scheme and hostname of the current server will be
210
<p>Then any request beginning with <em>URL-Path</em> will return a
211
redirect request to the client at the location of the target
212
<em>URL</em>. Additional path information beyond the matched
213
<em>URL-Path</em> will be appended to the target URL.</p>
215
<div class="example"><h3>Example:</h3><p><code>
216
Redirect /service http://foo2.example.com/service
219
<p>If the client requests http://example.com/service/foo.txt, it
220
will be told to access http://foo2.example.com/service/foo.txt
221
instead. Only complete path segments are matched, so the above
222
example would not match a request for
223
http://example.com/servicefoo.txt. For more complex matching
224
using regular expressions, see the <code class="directive"><a href="#redirectmatch">RedirectMatch</a></code> directive.</p>
227
<div class="note"><h3>Note</h3> <p>Redirect directives take precedence over
228
Alias and ScriptAlias directives, irrespective of their ordering in
229
the configuration file.</p></div>
231
<p>If no <var>status</var> argument is given, the redirect will
232
be "temporary" (HTTP status 302). This indicates to the client
233
that the resource has moved temporarily. The <var>status</var>
234
argument can be used to return other HTTP status codes:</p>
239
<dd>Returns a permanent redirect status (301) indicating that
240
the resource has moved permanently.</dd>
244
<dd>Returns a temporary redirect status (302). This is the
249
<dd>Returns a "See Other" status (303) indicating that the
250
resource has been replaced.</dd>
254
<dd>Returns a "Gone" status (410) indicating that the
255
resource has been permanently removed. When this status is
256
used the <var>URL</var> argument should be omitted.</dd>
259
<p>Other status codes can be returned by giving the numeric
260
status code as the value of <var>status</var>. If the status is
261
between 300 and 399, the <var>URL</var> argument must be present,
262
otherwise it must be omitted. Note that the status must be
263
known to the Apache code (see the function
264
<code>send_error_response</code> in http_protocol.c).</p>
266
<div class="example"><h3>Example:</h3><p><code>
267
Redirect permanent /one http://example.com/two<br />
268
Redirect 303 /three http://example.com/other
273
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
274
<div class="directive-section"><h2><a name="RedirectMatch" id="RedirectMatch">RedirectMatch</a> <a name="redirectmatch" id="redirectmatch">Directive</a></h2>
275
<table class="directive">
276
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sends an external redirect based on a regular expression match
277
of the current URL</td></tr>
278
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RedirectMatch [<var>status</var>] <var>regex</var>
279
<var>URL</var></code></td></tr>
280
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
281
<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
282
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
283
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
285
<p>This directive is equivalent to <code class="directive"><a href="#redirect">Redirect</a></code>, but makes use of
286
<a class="glossarylink" href="../glossary.html#regex" title="see glossary">regular expressions</a>,
287
instead of simple prefix matching. The
288
supplied regular expression is matched against the URL-path, and
289
if it matches, the server will substitute any parenthesized
290
matches into the given string and use it as a filename. For
291
example, to redirect all GIF files to like-named JPEG files on
292
another server, one might use:</p>
294
<div class="example"><p><code>
295
RedirectMatch (.*)\.gif$ http://www.anotherserver.com$1.jpg
299
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
300
<div class="directive-section"><h2><a name="RedirectPermanent" id="RedirectPermanent">RedirectPermanent</a> <a name="redirectpermanent" id="redirectpermanent">Directive</a></h2>
301
<table class="directive">
302
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sends an external permanent redirect asking the client to fetch
303
a different URL</td></tr>
304
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RedirectPermanent <var>URL-path</var> <var>URL</var></code></td></tr>
305
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
306
<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
307
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
308
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
310
<p>This directive makes the client know that the Redirect is
311
permanent (status 301). Exactly equivalent to <code>Redirect
312
permanent</code>.</p>
315
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
316
<div class="directive-section"><h2><a name="RedirectTemp" id="RedirectTemp">RedirectTemp</a> <a name="redirecttemp" id="redirecttemp">Directive</a></h2>
317
<table class="directive">
318
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sends an external temporary redirect asking the client to fetch
319
a different URL</td></tr>
320
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RedirectTemp <var>URL-path</var> <var>URL</var></code></td></tr>
321
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
322
<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
323
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
324
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
326
<p>This directive makes the client know that the Redirect is
327
only temporary (status 302). Exactly equivalent to
328
<code>Redirect temp</code>.</p>
331
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
332
<div class="directive-section"><h2><a name="ScriptAlias" id="ScriptAlias">ScriptAlias</a> <a name="scriptalias" id="scriptalias">Directive</a></h2>
333
<table class="directive">
334
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps a URL to a filesystem location and designates the
335
target as a CGI script</td></tr>
336
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ScriptAlias <var>URL-path</var>
337
<var>file-path</var>|<var>directory-path</var></code></td></tr>
338
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
339
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
340
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
342
<p>The <code class="directive">ScriptAlias</code> directive has the same
343
behavior as the <code class="directive"><a href="#alias">Alias</a></code>
344
directive, except that in addition it marks the target directory
345
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
346
(%-decoded) path beginning with <var>URL-path</var> will be mapped
347
to scripts beginning with the second argument which is a full
348
pathname in the local filesystem.</p>
350
<div class="example"><h3>Example:</h3><p><code>
351
ScriptAlias /cgi-bin/ /web/cgi-bin/
354
<p>A request for <code>http://myserver/cgi-bin/foo</code> would cause the
355
server to run the script <code>/web/cgi-bin/foo</code>.</p>
358
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
359
<div class="directive-section"><h2><a name="ScriptAliasMatch" id="ScriptAliasMatch">ScriptAliasMatch</a> <a name="scriptaliasmatch" id="scriptaliasmatch">Directive</a></h2>
360
<table class="directive">
361
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps a URL to a filesystem location using a regular expression
362
and designates the target as a CGI script</td></tr>
363
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ScriptAliasMatch <var>regex</var>
364
<var>file-path</var>|<var>directory-path</var></code></td></tr>
365
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
366
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
367
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
369
<p>This directive is equivalent to <code class="directive"><a href="#scriptalias">ScriptAlias</a></code>, but makes use of
370
<a class="glossarylink" href="../glossary.html#regex" title="see glossary">regular expressions</a>,
371
instead of simple prefix matching. The
372
supplied regular expression is matched against the URL-path,
373
and if it matches, the server will substitute any parenthesized
374
matches into the given string and use it as a filename. For
375
example, to activate the standard <code>/cgi-bin</code>, one
378
<div class="example"><p><code>
379
ScriptAliasMatch ^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
384
<div class="bottomlang">
385
<p><span>Available Languages: </span><a href="../en/mod/mod_alias.html" title="English"> en </a> |
386
<a href="../ja/mod/mod_alias.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
387
<a href="../ko/mod/mod_alias.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p>
388
</div><div id="footer">
389
<p class="apache">Copyright 2006 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>
390
<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>
b'\\ No newline at end of file'