1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
6<html xmlns="http://www.w3.org/1999/xhtml">
7  <head>
8    <meta name="generator" content="HTML Tidy, see www.w3.org" />
9
10    <title>Apache module mod_alias</title>
11  </head>
12  <!-- Background white, links blue (unvisited), navy (visited), red (active) -->
13
14  <body bgcolor="#FFFFFF" text="#000000" link="#0000FF"
15  vlink="#000080" alink="#FF0000">
16        <div align="CENTER">
17      <img src="../images/sub.gif" alt="[APACHE DOCUMENTATION]" />
18
19      <h3>Apache HTTP Server Version 1.3</h3>
20    </div>
21
22
23    <h1 align="CENTER">Module mod_alias</h1>
24
25    <p>This module provides for mapping different parts of the host
26    filesystem in the document tree, and for URL redirection.</p>
27
28    <p><a href="module-dict.html#Status"
29    rel="Help"><strong>Status:</strong></a> Base<br />
30     <a href="module-dict.html#SourceFile"
31    rel="Help"><strong>Source File:</strong></a> mod_alias.c<br />
32     <a href="module-dict.html#ModuleIdentifier"
33    rel="Help"><strong>Module Identifier:</strong></a>
34    alias_module</p>
35
36    <h2>Summary</h2>
37
38    <p>The directives contained in this module allow for
39    manipulation and control of URLs as requests arrive at the
40    server. The <code>Alias</code> and <code>ScriptAlias</code>
41    directives are used to map between URLs and filesystem paths.
42    This allows for content which is not directly under the <a
43    href="core.html#documentroot"><code>DocumentRoot</code></a> to
44    be served as part of the web document tree. The
45    <code>ScriptAlias</code> directive has the additional effect of
46    marking the target directory as containing only CGI
47    scripts.</p>
48
49    <p>The <code>Redirect</code> directives are used to instruct
50    clients to make a new request with a different URL. They are
51    often used when a resource has moved to a new location.</p>
52
53    <p>A more powerful and flexible set of directives for
54    manipulating URLs is contained in the <a
55    href="mod_rewrite.html"><code>mod_rewrite</code></a>
56    module.</p>
57
58    <h2>Directives</h2>
59
60    <ul>
61      <li><a href="#alias">Alias</a></li>
62
63      <li><a href="#aliasmatch">AliasMatch</a></li>
64
65      <li><a href="#redirect">Redirect</a></li>
66
67      <li><a href="#redirectmatch">RedirectMatch</a></li>
68
69      <li><a href="#redirecttemp">RedirectTemp</a></li>
70
71      <li><a href="#redirectperm">RedirectPermanent</a></li>
72
73      <li><a href="#scriptalias">ScriptAlias</a></li>
74
75      <li><a href="#scriptaliasmatch">ScriptAliasMatch</a></li>
76    </ul>
77    <hr />
78
79    <h2><a id="alias" name="alias">Alias directive</a></h2>
80
81    <p>
82     <a href="directive-dict.html#Syntax"
83    rel="Help"><strong>Syntax:</strong></a> Alias <em>URL-path
84    file-path</em>|<em>directory-path</em><br />
85     <a href="directive-dict.html#Context"
86    rel="Help"><strong>Context:</strong></a> server config, virtual
87    host<br />
88     <a href="directive-dict.html#Status"
89    rel="Help"><strong>Status:</strong></a> Base<br />
90     <a href="directive-dict.html#Module"
91    rel="Help"><strong>Module:</strong></a> mod_alias</p>
92
93    <p>The Alias directive allows documents to be stored in the
94    local filesystem other than under the <a
95    href="core.html#documentroot">DocumentRoot</a>. URLs with a
96    (%-decoded) path beginning with <em>url-path</em> will be
97    mapped to local files beginning with
98    <em>directory-filename</em>.</p>
99
100    <p>Example:</p>
101
102    <blockquote>
103      <code>Alias /image /ftp/pub/image</code>
104    </blockquote>
105
106    <p>A request for http://myserver/image/foo.gif would cause the
107    server to return the file /ftp/pub/image/foo.gif.</p>
108
109    <p>Note that if you include a trailing / on the
110    <em>url-path</em> then the server will require a trailing / in
111    order to expand the alias. That is, if you use <code>Alias
112    /icons/ /usr/local/apache/icons/</code> then the url
113    <code>/icons</code> will not be aliased.</p>
114
115    <p>Note that you may need to specify additional <a
116    href="core.html#directory"><code>&lt;Directory&gt;</code></a>
117    sections which cover the <em>destination</em> of aliases.
118    Aliasing occurs before <code>&lt;Directory&gt;</code> sections
119    are checked, so only the destination of aliases are affected.
120    (Note however <a
121    href="core.html#location"><code>&lt;Location&gt;</code></a>
122    sections are run through once before aliases are performed, so
123    they will apply.)</p>
124
125    <p>See also <a href="#scriptalias">ScriptAlias</a>.</p>
126    <hr />
127
128    <h2><a id="aliasmatch" name="aliasmatch">AliasMatch</a></h2>
129
130    <p><a href="directive-dict.html#Syntax"
131    rel="Help"><strong>Syntax:</strong></a> AliasMatch <em>regex
132    file-path</em>|<em>directory-path</em><br />
133     <a href="directive-dict.html#Context"
134    rel="Help"><strong>Context:</strong></a> server config, virtual
135    host<br />
136     <a href="directive-dict.html#Status"
137    rel="Help"><strong>Status:</strong></a> Base<br />
138     <a href="directive-dict.html#Module"
139    rel="Help"><strong>Module:</strong></a> mod_alias<br />
140     <a href="directive-dict.html#Compatibility"
141    rel="Help"><strong>Compatibility:</strong></a> Available in
142    Apache 1.3 and later</p>
143
144    <p>This directive is equivalent to <a href="#alias">Alias</a>,
145    but makes use of standard regular expressions, instead of
146    simple prefix matching. The supplied regular expression is
147    matched against the URL-path, and if it matches, the server
148    will substitute any parenthesized matches into the given string
149    and use it as a filename. For example, to activate the
150    <code>/icons</code> directory, one might use:</p>
151<pre>
152    AliasMatch ^/icons(.*) /usr/local/apache/icons$1
153</pre>
154    <hr />
155
156    <h2><a id="redirect" name="redirect">Redirect
157    directive</a></h2>
158
159    <p>
160     <a href="directive-dict.html#Syntax"
161    rel="Help"><strong>Syntax:</strong></a> Redirect
162    [<em>status</em>] <em>URL-path URL</em><br />
163     <a href="directive-dict.html#Context"
164    rel="Help"><strong>Context:</strong></a> server config, virtual
165    host, directory, .htaccess<br />
166     <a href="directive-dict.html#Override"
167    rel="Help"><strong>Override:</strong></a> FileInfo<br />
168     <a href="directive-dict.html#Status"
169    rel="Help"><strong>Status:</strong></a> Base<br />
170     <a href="directive-dict.html#Module"
171    rel="Help"><strong>Module:</strong></a> mod_alias<br />
172     <a href="directive-dict.html#Compatibility"
173    rel="Help"><strong>Compatibility:</strong></a> The directory
174    and .htaccess context's are only available in versions 1.1 and
175    later. The <em>status</em> argument is only available in Apache
176    1.2 or later.</p>
177
178    <p>The Redirect directive maps an old URL into a new one. The
179    new URL is returned to the client which attempts to fetch it
180    again with the new address. <em>URL-path</em> a (%-decoded)
181    path; any requests for documents beginning with this path will
182    be returned a redirect error to a new (%-encoded) URL beginning
183    with <em>URL</em>.</p>
184
185    <p>Example:</p>
186
187    <blockquote>
188      <code>Redirect /service http://foo2.bar.com/service</code>
189    </blockquote>
190
191    <p>If the client requests http://myserver/service/foo.txt, it
192    will be told to access http://foo2.bar.com/service/foo.txt
193    instead.</p>
194
195    <p><strong>Note:</strong> Redirect directives take precedence
196    over Alias and ScriptAlias directives, irrespective of their
197    ordering in the configuration file. Also, <em>URL-path</em>
198    must be a fully qualified URL, not a relative path, even when used
199    with .htaccess files or inside of &lt;Directory&gt;
200    sections.</p>
201
202    <p>If no <em>status</em> argument is given, the redirect will
203    be "temporary" (HTTP status 302). This indicates to the client
204    that the resource has moved temporarily. The <em>status</em>
205    argument can be used to return other HTTP status codes:</p>
206
207    <dl>
208      <dt>permanent</dt>
209
210      <dd>Returns a permanent redirect status (301) indicating that
211      the resource has moved permanently.</dd>
212
213      <dt>temp</dt>
214
215      <dd>Returns a temporary redirect status (302). This is the
216      default.</dd>
217
218      <dt>seeother</dt>
219
220      <dd>Returns a "See Other" status (303) indicating that the
221      resource has been replaced.</dd>
222
223      <dt>gone</dt>
224
225      <dd>Returns a "Gone" status (410) indicating that the
226      resource has been permanently removed. When this status is
227      used the <em>url</em> argument should be omitted.</dd>
228    </dl>
229
230    <p>Other status codes can be returned by giving the numeric
231    status code as the value of <em>status</em>. If the status is
232    between 300 and 399, the <em>url</em> argument must be present,
233    otherwise it must be omitted. Note that the status must be
234    known to the Apache code (see the function
235    <code>send_error_response</code> in http_protocol.c).</p>
236
237    <p>Example:</p>
238
239    <pre>
240    Redirect permanent /one http://example.com/two<br />
241    Redirect 303 /two http://example.com/other
242    </pre>
243    <hr />
244
245    <h2><a id="redirectmatch"
246    name="redirectmatch">RedirectMatch</a></h2>
247
248    <p><a href="directive-dict.html#Syntax"
249    rel="Help"><strong>Syntax:</strong></a> RedirectMatch
250    [<em>status</em>] <em>regex URL</em><br />
251     <a href="directive-dict.html#Context"
252    rel="Help"><strong>Context:</strong></a> server config, virtual
253    host, directory, .htaccess<br />
254     <a href="directive-dict.html#Override"
255    rel="Help"><strong>Override:</strong></a> FileInfo<br />
256     <a href="directive-dict.html#Status"
257    rel="Help"><strong>Status:</strong></a> Base<br />
258     <a href="directive-dict.html#Module"
259    rel="Help"><strong>Module:</strong></a> mod_alias<br />
260     <a href="directive-dict.html#Compatibility"
261    rel="Help"><strong>Compatibility:</strong></a> Available in
262    Apache 1.3 and later</p>
263
264    <p>This directive is equivalent to <a
265    href="#redirect">Redirect</a>, but makes use of standard
266    regular expressions, instead of simple prefix matching. The
267    supplied regular expression is matched against the URL-path,
268    and if it matches, the server will substitute any parenthesized
269    matches into the given string and use it as a filename. For
270    example, to redirect all GIF files to like-named JPEG files on
271    another server, one might use:</p>
272<pre>
273    RedirectMatch (.*)\.gif$ http://www.anotherserver.com$1.jpg
274</pre>
275    <hr />
276
277    <h2><a id="redirecttemp" name="redirecttemp">RedirectTemp
278    directive</a></h2>
279
280    <p>
281     <a href="directive-dict.html#Syntax"
282    rel="Help"><strong>Syntax:</strong></a> RedirectTemp
283    <em>URL-path URL</em><br />
284     <a href="directive-dict.html#Context"
285    rel="Help"><strong>Context:</strong></a> server config, virtual
286    host, directory, .htaccess<br />
287     <a href="directive-dict.html#Override"
288    rel="Help"><strong>Override:</strong></a> FileInfo<br />
289     <a href="directive-dict.html#Status"
290    rel="Help"><strong>Status:</strong></a> Base<br />
291     <a href="directive-dict.html#Module"
292    rel="Help"><strong>Module:</strong></a> mod_alias<br />
293     <a href="directive-dict.html#Compatibility"
294    rel="Help"><strong>Compatibility:</strong></a> This directive
295    is only available in Apache 1.2 and later</p>
296
297    <p>This directive makes the client know that the Redirect is
298    only temporary (status 302). Exactly equivalent to
299    <code>Redirect temp</code>.</p>
300    <hr />
301
302    <h2><a id="redirectperm" name="redirectperm">RedirectPermanent
303    directive</a></h2>
304
305    <p>
306     <a href="directive-dict.html#Syntax"
307    rel="Help"><strong>Syntax:</strong></a> RedirectPermanent
308    <em>URL-path URL</em><br />
309     <a href="directive-dict.html#Context"
310    rel="Help"><strong>Context:</strong></a> server config, virtual
311    host, directory, .htaccess<br />
312     <a href="directive-dict.html#Override"
313    rel="Help"><strong>Override:</strong></a> FileInfo<br />
314     <a href="directive-dict.html#Status"
315    rel="Help"><strong>Status:</strong></a> Base<br />
316     <a href="directive-dict.html#Module"
317    rel="Help"><strong>Module:</strong></a> mod_alias<br />
318     <a href="directive-dict.html#Compatibility"
319    rel="Help"><strong>Compatibility:</strong></a> This directive
320    is only available in Apache 1.2 and later</p>
321
322    <p>This directive makes the client know that the Redirect is
323    permanent (status 301). Exactly equivalent to <code>Redirect
324    permanent</code>.</p>
325    <hr />
326
327    <h2><a id="scriptalias" name="scriptalias">ScriptAlias
328    directive</a></h2>
329
330    <p>
331     <a href="directive-dict.html#Syntax"
332    rel="Help"><strong>Syntax:</strong></a> ScriptAlias
333    <em>URL-path file-path</em>|<em>directory-path</em><br />
334     <a href="directive-dict.html#Context"
335    rel="Help"><strong>Context:</strong></a> server config, virtual
336    host<br />
337     <a href="directive-dict.html#Status"
338    rel="Help"><strong>Status:</strong></a> Base<br />
339     <a href="directive-dict.html#Module"
340    rel="Help"><strong>Module:</strong></a> mod_alias</p>
341
342    <p>The ScriptAlias directive has the same behavior as the <a
343    href="#alias">Alias</a> directive, except that in addition it
344    marks the target directory as containing CGI scripts that will be
345    processed by <a href="mod_cgi.html">mod_cgi</a>'s cgi-script
346    handler. URLs with a (%-decoded) path beginning with
347    <em>URL-path</em> will be mapped to scripts beginning with the
348    second argument which is a full pathname in the local
349    filesystem.</p>
350
351    <p>Example:</p>
352
353    <blockquote>
354      <code>ScriptAlias /cgi-bin/ /web/cgi-bin/</code>
355    </blockquote>
356
357    <p>A request for http://myserver/cgi-bin/foo would cause the
358    server to run the script /web/cgi-bin/foo.</p>
359    <hr />
360
361    <h2><a id="scriptaliasmatch"
362    name="scriptaliasmatch">ScriptAliasMatch</a></h2>
363
364    <p><a href="directive-dict.html#Syntax"
365    rel="Help"><strong>Syntax:</strong></a> ScriptAliasMatch
366    <em>regex file-path</em>|<em>directory-path</em><br />
367     <a href="directive-dict.html#Context"
368    rel="Help"><strong>Context:</strong></a> server config, virtual
369    host<br />
370     <a href="directive-dict.html#Status"
371    rel="Help"><strong>Status:</strong></a> Base<br />
372     <a href="directive-dict.html#Module"
373    rel="Help"><strong>Module:</strong></a> mod_alias<br />
374     <a href="directive-dict.html#Compatibility"
375    rel="Help"><strong>Compatibility:</strong></a> Available in
376    Apache 1.3 and later</p>
377
378    <p>This directive is equivalent to <a
379    href="#scriptalias">ScriptAlias</a>, but makes use of standard
380    regular expressions, instead of simple prefix matching. The
381    supplied regular expression is matched against the URL-path,
382    and if it matches, the server will substitute any parenthesized
383    matches into the given string and use it as a filename. For
384    example, to activate the standard <code>/cgi-bin</code>, one
385    might use:</p>
386<pre>
387    ScriptAliasMatch ^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
388</pre>
389        <hr />
390
391    <h3 align="CENTER">Apache HTTP Server Version 1.3</h3>
392    <a href="./"><img src="../images/index.gif" alt="Index" /></a>
393    <a href="../"><img src="../images/home.gif" alt="Home" /></a>
394
395  </body>
396</html>
397
398
399