]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_alias.html
Another pass at the normalisation of the HTML tags. Some
[apache] / docs / manual / mod / mod_alias.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2 <HTML>
3 <HEAD>
4 <TITLE>Apache module mod_alias</TITLE>
5 </HEAD>
6
7 <!-- Background white, links blue (unvisited), navy (visited), red (active) -->
8 <BODY
9  BGCOLOR="#FFFFFF"
10  TEXT="#000000"
11  LINK="#0000FF"
12  VLINK="#000080"
13  ALINK="#FF0000"
14 >
15 <!--#include virtual="header.html" -->
16
17 <H1 ALIGN="CENTER">Module mod_alias</H1>
18 <P>
19 This module is contained in the <CODE>mod_alias.c</CODE> file, and
20 is compiled in by default. It provides for mapping different parts of the
21 host filesystem in the the document tree, and for URL redirection.
22 </P>
23
24 <H2>Directives</H2>
25 <UL>
26 <LI><A HREF="#alias">Alias</A>
27 <LI><A HREF="#aliasmatch">AliasMatch</A>
28 <LI><A HREF="#redirect">Redirect</A>
29 <LI><A HREF="#redirectmatch">RedirectMatch</A>
30 <LI><A HREF="#redirecttemp">RedirectTemp</A>
31 <LI><A HREF="#redirectperm">RedirectPermanent</A>
32 <LI><A HREF="#scriptalias">ScriptAlias</A>
33 <LI><A HREF="#scriptaliasmatch">ScriptAliasMatch</A>
34 </UL>
35 <HR>
36
37
38 <H2><A name="alias">Alias directive</A></H2>
39 <P>
40 <!--%plaintext &lt;?INDEX {\tt Alias} directive&gt; -->
41 <A
42  HREF="directive-dict.html#Syntax"
43  REL="Help"
44 ><STRONG>Syntax:</STRONG></A> Alias <EM>url-path directory-filename</EM><BR>
45 <A
46  HREF="directive-dict.html#Context"
47  REL="Help"
48 ><STRONG>Context:</STRONG></A> server config, virtual host<BR>
49 <A
50  HREF="directive-dict.html#Status"
51  REL="Help"
52 ><STRONG>Status:</STRONG></A> Base<BR>
53 <A
54  HREF="directive-dict.html#Module"
55  REL="Help"
56 ><STRONG>Module:</STRONG></A> mod_alias
57 </P>
58 <P>
59 The Alias directive allows documents to be stored in the local filesystem
60 other than under the <A HREF="core.html#documentroot">DocumentRoot</A>.
61 URLs with a (%-decoded) path beginning with <EM>url-path</EM> will be
62 mapped to local files beginning with <EM>directory-filename</EM>.
63 <P>
64 Example:
65 </P>
66 <BLOCKQUOTE><CODE>Alias /image /ftp/pub/image</CODE></BLOCKQUOTE>
67 <P>
68 A request for http://myserver/image/foo.gif would cause the server to
69 return the file /ftp/pub/image/foo.gif.
70 </P>
71 <P>
72 Note that if you include a trailing / on the <EM>url-path</EM> then the
73 server will require a trailing / in order to expand the alias.  That is,
74 if you use <CODE>Alias /icons/ /usr/local/apache/icons/</CODE> then
75 the url <CODE>/icons</CODE> will not be aliased.
76 </P>
77 <P>
78 See also <A HREF="#scriptalias">ScriptAlias</A>.
79 </P>
80 <HR>
81
82 <H2><A name="aliasmatch">AliasMatch</A></H2>
83 <P>
84 <A
85  HREF="directive-dict.html#Syntax"
86  REL="Help"
87 ><STRONG>Syntax:</STRONG></A> AliasMatch <EM>regex directory-filename</EM><BR>
88 <A
89  HREF="directive-dict.html#Context"
90  REL="Help"
91 ><STRONG>Context:</STRONG></A> server config, virtual host<BR>
92 <A
93  HREF="directive-dict.html#Status"
94  REL="Help"
95 ><STRONG>Status:</STRONG></A> Base<BR>
96 <A
97  HREF="directive-dict.html#Module"
98  REL="Help"
99 ><STRONG>Module:</STRONG></A> mod_alias<BR>
100 <A
101  HREF="directive-dict.html#Compatibility"
102  REL="Help"
103 ><STRONG>Compatibility:</STRONG></A> Available in Apache 1.3 and later
104 </P>
105
106 <P>This directive is equivalent to <A HREF="#alias">Alias</A>, but
107 makes use of standard regular expressions, instead of simple prefix
108 matching. The supplied regular expression is matched against the URL,
109 and if it matches, the server will substitute any parenthesized
110 matches into the given string and use it as a filename. For example,
111 to activate the <CODE>/icons</CODE> directory, one might use:
112 <PRE>
113     AliasMatch ^/icons(.*) /usr/local/apache/icons$1
114 </PRE>
115 </P>
116
117 <HR>
118
119 <H2><A name="redirect">Redirect directive</A></H2>
120 <P>
121 <!--%plaintext &lt;?INDEX {\tt Redirect} directive&gt; -->
122 <A
123  HREF="directive-dict.html#Syntax"
124  REL="Help"
125 ><STRONG>Syntax:</STRONG></A> Redirect [ <EM>status</EM> ] <EM>url-path url</EM><BR>
126 <A
127  HREF="directive-dict.html#Context"
128  REL="Help"
129 ><STRONG>Context:</STRONG></A> server config, virtual host, directory, .htaccess<BR>
130 <A
131  HREF="directive-dict.html#Status"
132  REL="Help"
133 ><STRONG>Status:</STRONG></A> Base<BR>
134 <A
135  HREF="directive-dict.html#Module"
136  REL="Help"
137 ><STRONG>Module:</STRONG></A> mod_alias<BR>
138 <A
139  HREF="directive-dict.html#Compatibility"
140  REL="Help"
141 ><STRONG>Compatibility:</STRONG></A> The directory and .htaccess context's
142 are only available in versions 1.1 and later. The <EM>status</EM>
143 argument is only available in Apache 1.2 or later.
144 </P>
145 <P>
146 The Redirect directive maps an old URL into a new one. The new URL is returned
147 to the client which attempts to fetch it again with the new address.
148 <EM>Url-path</EM> a (%-decoded) path; any requests for documents beginning with
149 this path will be returned a redirect error to a new (%-encoded) url
150 beginning with <EM>url</EM>.
151 </P>
152 <P>
153 Example:
154 </P>
155 <BLOCKQUOTE><CODE>Redirect /service
156 http://foo2.bar.com/service</CODE></BLOCKQUOTE>
157 <P>
158 If the client requests http://myserver/service/foo.txt, it will be told to
159 access http://foo2.bar.com/service/foo.txt instead.
160 </P>
161 <P>
162 <STRONG>Note:</STRONG> Redirect directives take precedence over Alias
163 and ScriptAlias
164 directives, irrespective of their ordering in the configuration file.  Also,
165 <EM>Url-path</EM> must be an absolute path, not a relative path, even
166 when used with .htaccess files or inside of &lt;Directory&gt; sections.
167 </P>
168 <P>
169 If no <EM>status</EM> argument is given, the redirect will be
170 &quot;temporary&quot; (HTTP status 302). This indicates to the client that the
171 resources is has moved temporarily. The <EM>status</EM>
172 argument can be used to return other HTTP status codes:
173 <P>
174 <DL>
175 <DT>permanent
176 <DD>Returns a permanent redirect status (301) indicating that
177 the resource has moved permanently.
178 <DT>temp
179 <DD>Returns a temporary redirect status (302). This is the
180 default.
181 <DT>seeother
182 <DD>Returns a "See Other" status (303) indicating that
183 the resource has been replaced.
184 <DT>gone
185 <DD>Returns a "Gone" status (410) indicating that the resource
186 has been permanently removed. When this status is used the <EM>url</EM>
187 argument should be omitted.
188 </DL>
189 <P>
190 Other status codes can be returned by giving the numeric status code
191 as the value of <EM>status</EM>. If the status is between 300 and 399,
192 the <EM>url</EM> argument must be present, otherwise it must be
193 omitted. Note that the status must be known to the Apache code (see
194 the function <CODE>send_error_response</CODE> in http_protocol.c).
195 </P>
196 <HR>
197
198 <H2><A name="redirectmatch">RedirectMatch</A></H2>
199 <P>
200 <A
201  HREF="directive-dict.html#Syntax"
202  REL="Help"
203 ><STRONG>Syntax:</STRONG></A> RedirectMatch [<EM>status</EM> <EM>regex url</EM><BR>
204 <A
205  HREF="directive-dict.html#Context"
206  REL="Help"
207 ><STRONG>Context:</STRONG></A> server config, virtual host<BR>
208 <A
209  HREF="directive-dict.html#Status"
210  REL="Help"
211 ><STRONG>Status:</STRONG></A> Base<BR>
212 <A
213  HREF="directive-dict.html#Module"
214  REL="Help"
215 ><STRONG>Module:</STRONG></A> mod_alias<BR>
216 <A
217  HREF="directive-dict.html#Compatibility"
218  REL="Help"
219 ><STRONG>Compatibility:</STRONG></A> Available in Apache 1.3 and later
220 </P>
221
222 <P>This directive is equivalent to <A HREF="#alias">Redirect</A>, but
223 makes use of standard regular expressions, instead of simple prefix
224 matching. The supplied regular expression is matched against the URL,
225 and if it matches, the server will substitute any parenthesized
226 matches into the given string and use it as a filename. For example,
227 to redirect all GIF files to like-named JPEG files on another server,
228 one might use:
229 <PRE>
230     RedirectMatch (.*)\.gif$ http://www.anotherserver.com$1.jpg
231 </PRE>
232 </P>
233
234 <HR>
235
236 <H2><A name="redirecttemp">RedirectTemp directive</A></H2>
237 <P>
238 <!--%plaintext &lt;?INDEX {\tt Redirect} directive&gt; -->
239 <A
240  HREF="directive-dict.html#Syntax"
241  REL="Help"
242 ><STRONG>Syntax:</STRONG></A> RedirectTemp <EM>url-path url</EM><BR>
243 <A
244  HREF="directive-dict.html#Context"
245  REL="Help"
246 ><STRONG>Context:</STRONG></A> server config, virtual host, directory, .htaccess<BR>
247 <A
248  HREF="directive-dict.html#Status"
249  REL="Help"
250 ><STRONG>Status:</STRONG></A> Base<BR>
251 <A
252  HREF="directive-dict.html#Module"
253  REL="Help"
254 ><STRONG>Module:</STRONG></A> mod_alias<BR>
255 <A
256  HREF="directive-dict.html#Compatibility"
257  REL="Help"
258 ><STRONG>Compatibility:</STRONG></A> This directive is only available in 1.2
259 </P>
260 <P>
261 This directive makes the client know that the Redirect is only
262 temporary (status 302). Exactly equivalent to <CODE>Redirect
263 temporary</CODE>.
264 </P>
265 <HR>
266
267 <H2><A name="redirectperm">RedirectPermanent directive</A></H2>
268 <P>
269 <!--%plaintext &lt;?INDEX {\tt Redirect} directive&gt; -->
270 <A
271  HREF="directive-dict.html#Syntax"
272  REL="Help"
273 ><STRONG>Syntax:</STRONG></A> RedirectPermanent <EM>url-path url</EM><BR>
274 <A
275  HREF="directive-dict.html#Context"
276  REL="Help"
277 ><STRONG>Context:</STRONG></A> server config, virtual host, directory, .htaccess<BR>
278 <A
279  HREF="directive-dict.html#Status"
280  REL="Help"
281 ><STRONG>Status:</STRONG></A> Base<BR>
282 <A
283  HREF="directive-dict.html#Module"
284  REL="Help"
285 ><STRONG>Module:</STRONG></A> mod_alias<BR>
286 <A
287  HREF="directive-dict.html#Compatibility"
288  REL="Help"
289 ><STRONG>Compatibility:</STRONG></A> This directive is only available in 1.2
290 </P>
291 <P>
292 This directive makes the client know that the Redirect is permanent
293 (status 301). Exactly equivalent to <CODE>Redirect permanent</CODE>.
294 </P>
295 <HR>
296
297 <H2><A name="scriptalias">ScriptAlias directive</A></H2>
298 <P>
299 <!--%plaintext &lt;?INDEX {\tt ScriptAlias} directive&gt; -->
300 <A
301  HREF="directive-dict.html#Syntax"
302  REL="Help"
303 ><STRONG>Syntax:</STRONG></A> ScriptAlias <EM>url-path directory-filename</EM><BR>
304 <A
305  HREF="directive-dict.html#Context"
306  REL="Help"
307 ><STRONG>Context:</STRONG></A> server config, virtual host<BR>
308 <A
309  HREF="directive-dict.html#Status"
310  REL="Help"
311 ><STRONG>Status:</STRONG></A> Base<BR>
312 <A
313  HREF="directive-dict.html#Module"
314  REL="Help"
315 ><STRONG>Module:</STRONG></A> mod_alias
316 </P>
317 <P>
318 The ScriptAlias directive has the same behavior as the
319 <A HREF="#alias">Alias</A> directive, except that in addition it
320 marks the target directory as containing CGI scripts.
321 URLs with a (%-decoded) path beginning with <EM>url-path</EM> will be
322 mapped to scripts beginning with <EM>directory-filename</EM>.
323 <P>
324 Example:
325 </P>
326 <BLOCKQUOTE><CODE>ScriptAlias /cgi-bin/ /web/cgi-bin/</CODE></BLOCKQUOTE>
327 <P>
328 A request for http://myserver/cgi-bin/foo would cause the server to
329 run the script /web/cgi-bin/foo.
330 </P>
331
332 <HR>
333
334 <H2><A name="scriptaliasmatch">ScriptAliasMatch</A></H2>
335 <P>
336 <A
337  HREF="directive-dict.html#Syntax"
338  REL="Help"
339 ><STRONG>Syntax:</STRONG></A> ScriptAliasMatch <EM>regex directory-filename</EM><BR>
340 <A
341  HREF="directive-dict.html#Context"
342  REL="Help"
343 ><STRONG>Context:</STRONG></A> server config, virtual host<BR>
344 <A
345  HREF="directive-dict.html#Status"
346  REL="Help"
347 ><STRONG>Status:</STRONG></A> Base<BR>
348 <A
349  HREF="directive-dict.html#Module"
350  REL="Help"
351 ><STRONG>Module:</STRONG></A> mod_alias<BR>
352 <A
353  HREF="directive-dict.html#Compatibility"
354  REL="Help"
355 ><STRONG>Compatibility:</STRONG></A> Available in Apache 1.3 and later
356 </P>
357
358 <P>This directive is equivalent to <A HREF="#scriptalias">ScriptAlias</A>, but
359 makes use of standard regular expressions, instead of simple prefix
360 matching. The supplied regular expression is matched against the URL,
361 and if it matches, the server will substitute any parenthesized
362 matches into the given string and use it as a filename. For example,
363 to activate the standard <CODE>/cgi-bin</CODE>, one might use:
364 <PRE>
365     ScriptAliasMatch ^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
366 </PRE>
367 </P>
368
369 <!--#include virtual="footer.html" -->
370 </BODY>
371 </HTML>