]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_alias.html
Typo.
[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 Note that you may need to specify additional
79 <A HREF="core.html#directory"><CODE>&lt;Directory&gt;</CODE></A> sections
80 which cover the <EM>destination</EM> of aliases.  Aliasing occurs
81 before <CODE>&lt;Directory&gt;</CODE> sections are checked, so only
82 the destination of aliases are affected.  (Note however
83 <A HREF="core.html#location"><CODE>&lt;Location&gt;</CODE></A>
84 sections are run through once before aliases are performed, so they
85 will apply.)
86 <P>
87 See also <A HREF="#scriptalias">ScriptAlias</A>.
88 </P>
89 <HR>
90
91 <H2><A NAME="aliasmatch">AliasMatch</A></H2>
92 <P>
93 <A
94  HREF="directive-dict.html#Syntax"
95  REL="Help"
96 ><STRONG>Syntax:</STRONG></A> AliasMatch <EM>regex directory-filename</EM><BR>
97 <A
98  HREF="directive-dict.html#Context"
99  REL="Help"
100 ><STRONG>Context:</STRONG></A> server config, virtual host<BR>
101 <A
102  HREF="directive-dict.html#Status"
103  REL="Help"
104 ><STRONG>Status:</STRONG></A> Base<BR>
105 <A
106  HREF="directive-dict.html#Module"
107  REL="Help"
108 ><STRONG>Module:</STRONG></A> mod_alias<BR>
109 <A
110  HREF="directive-dict.html#Compatibility"
111  REL="Help"
112 ><STRONG>Compatibility:</STRONG></A> Available in Apache 1.3 and later
113 </P>
114
115 <P>This directive is equivalent to <A HREF="#alias">Alias</A>, but
116 makes use of standard regular expressions, instead of simple prefix
117 matching. The supplied regular expression is matched against the URL,
118 and if it matches, the server will substitute any parenthesized
119 matches into the given string and use it as a filename. For example,
120 to activate the <CODE>/icons</CODE> directory, one might use:
121 <PRE>
122     AliasMatch ^/icons(.*) /usr/local/apache/icons$1
123 </PRE>
124 </P>
125
126 <HR>
127
128 <H2><A NAME="redirect">Redirect directive</A></H2>
129 <P>
130 <!--%plaintext &lt;?INDEX {\tt Redirect} directive&gt; -->
131 <A
132  HREF="directive-dict.html#Syntax"
133  REL="Help"
134 ><STRONG>Syntax:</STRONG></A> Redirect [ <EM>status</EM> ]
135  <EM>url-path url</EM><BR>
136 <A
137  HREF="directive-dict.html#Context"
138  REL="Help"
139 ><STRONG>Context:</STRONG></A> server config, virtual host, directory,
140  .htaccess<BR>
141 <A
142  HREF="directive-dict.html#Override"
143  REL="Help"
144 ><STRONG>Override:</STRONG></A> FileInfo<BR>
145 <A
146  HREF="directive-dict.html#Status"
147  REL="Help"
148 ><STRONG>Status:</STRONG></A> Base<BR>
149 <A
150  HREF="directive-dict.html#Module"
151  REL="Help"
152 ><STRONG>Module:</STRONG></A> mod_alias<BR>
153 <A
154  HREF="directive-dict.html#Compatibility"
155  REL="Help"
156 ><STRONG>Compatibility:</STRONG></A> The directory and .htaccess context's
157 are only available in versions 1.1 and later. The <EM>status</EM>
158 argument is only available in Apache 1.2 or later.
159 </P>
160 <P>
161 The Redirect directive maps an old URL into a new one. The new URL is returned
162 to the client which attempts to fetch it again with the new address.
163 <EM>Url-path</EM> a (%-decoded) path; any requests for documents beginning with
164 this path will be returned a redirect error to a new (%-encoded) url
165 beginning with <EM>url</EM>.
166 </P>
167 <P>
168 Example:
169 </P>
170 <BLOCKQUOTE><CODE>Redirect /service
171 http://foo2.bar.com/service</CODE></BLOCKQUOTE>
172 <P>
173 If the client requests http://myserver/service/foo.txt, it will be told to
174 access http://foo2.bar.com/service/foo.txt instead.
175 </P>
176 <P>
177 <STRONG>Note:</STRONG> Redirect directives take precedence over Alias
178 and ScriptAlias
179 directives, irrespective of their ordering in the configuration file.  Also,
180 <EM>Url-path</EM> must be an absolute path, not a relative path, even
181 when used with .htaccess files or inside of &lt;Directory&gt; sections.
182 </P>
183 <P>
184 If no <EM>status</EM> argument is given, the redirect will be
185 &quot;temporary&quot; (HTTP status 302). This indicates to the client that the
186 resources is has moved temporarily. The <EM>status</EM>
187 argument can be used to return other HTTP status codes:
188 <P>
189 <DL>
190 <DT>permanent
191 <DD>Returns a permanent redirect status (301) indicating that
192 the resource has moved permanently.
193 <DT>temp
194 <DD>Returns a temporary redirect status (302). This is the
195 default.
196 <DT>seeother
197 <DD>Returns a "See Other" status (303) indicating that
198 the resource has been replaced.
199 <DT>gone
200 <DD>Returns a "Gone" status (410) indicating that the resource
201 has been permanently removed. When this status is used the <EM>url</EM>
202 argument should be omitted.
203 </DL>
204 <P>
205 Other status codes can be returned by giving the numeric status code
206 as the value of <EM>status</EM>. If the status is between 300 and 399,
207 the <EM>url</EM> argument must be present, otherwise it must be
208 omitted. Note that the status must be known to the Apache code (see
209 the function <CODE>send_error_response</CODE> in http_protocol.c).
210 </P>
211 <HR>
212
213 <H2><A NAME="redirectmatch">RedirectMatch</A></H2>
214 <P>
215 <A
216  HREF="directive-dict.html#Syntax"
217  REL="Help"
218 ><STRONG>Syntax:</STRONG></A>
219     RedirectMatch [<EM>status</EM>] <EM>regex url</EM>
220 <BR>
221 <A
222  HREF="directive-dict.html#Context"
223  REL="Help"
224 ><STRONG>Context:</STRONG></A> server config, virtual host<BR>
225 <A
226  HREF="directive-dict.html#Override"
227  REL="Help"
228 ><STRONG>Override:</STRONG></A> FileInfo<BR>
229 <A
230  HREF="directive-dict.html#Status"
231  REL="Help"
232 ><STRONG>Status:</STRONG></A> Base<BR>
233 <A
234  HREF="directive-dict.html#Module"
235  REL="Help"
236 ><STRONG>Module:</STRONG></A> mod_alias<BR>
237 <A
238  HREF="directive-dict.html#Compatibility"
239  REL="Help"
240 ><STRONG>Compatibility:</STRONG></A> Available in Apache 1.3 and later
241 </P>
242
243 <P>This directive is equivalent to <A HREF="#alias">Redirect</A>, but
244 makes use of standard regular expressions, instead of simple prefix
245 matching. The supplied regular expression is matched against the URL,
246 and if it matches, the server will substitute any parenthesized
247 matches into the given string and use it as a filename. For example,
248 to redirect all GIF files to like-named JPEG files on another server,
249 one might use:
250 <PRE>
251     RedirectMatch (.*)\.gif$ http://www.anotherserver.com$1.jpg
252 </PRE>
253 </P>
254
255 <HR>
256
257 <H2><A NAME="redirecttemp">RedirectTemp directive</A></H2>
258 <P>
259 <!--%plaintext &lt;?INDEX {\tt Redirect} directive&gt; -->
260 <A
261  HREF="directive-dict.html#Syntax"
262  REL="Help"
263 ><STRONG>Syntax:</STRONG></A> RedirectTemp <EM>url-path url</EM><BR>
264 <A
265  HREF="directive-dict.html#Context"
266  REL="Help"
267 ><STRONG>Context:</STRONG></A> server config, virtual host, directory,
268  .htaccess<BR>
269 <A
270  HREF="directive-dict.html#Override"
271  REL="Help"
272 ><STRONG>Override:</STRONG></A> FileInfo<BR>
273 <A
274  HREF="directive-dict.html#Status"
275  REL="Help"
276 ><STRONG>Status:</STRONG></A> Base<BR>
277 <A
278  HREF="directive-dict.html#Module"
279  REL="Help"
280 ><STRONG>Module:</STRONG></A> mod_alias<BR>
281 <A
282  HREF="directive-dict.html#Compatibility"
283  REL="Help"
284 ><STRONG>Compatibility:</STRONG></A> This directive is only available in 1.2
285 </P>
286 <P>
287 This directive makes the client know that the Redirect is only
288 temporary (status 302). Exactly equivalent to <CODE>Redirect
289 temp</CODE>.
290 </P>
291 <HR>
292
293 <H2><A NAME="redirectperm">RedirectPermanent directive</A></H2>
294 <P>
295 <!--%plaintext &lt;?INDEX {\tt Redirect} directive&gt; -->
296 <A
297  HREF="directive-dict.html#Syntax"
298  REL="Help"
299 ><STRONG>Syntax:</STRONG></A> RedirectPermanent <EM>url-path url</EM><BR>
300 <A
301  HREF="directive-dict.html#Context"
302  REL="Help"
303 ><STRONG>Context:</STRONG></A> server config, virtual host, directory,
304  .htaccess<BR>
305 <A
306  HREF="directive-dict.html#Override"
307  REL="Help"
308 ><STRONG>Override:</STRONG></A> FileInfo<BR>
309 <A
310  HREF="directive-dict.html#Status"
311  REL="Help"
312 ><STRONG>Status:</STRONG></A> Base<BR>
313 <A
314  HREF="directive-dict.html#Module"
315  REL="Help"
316 ><STRONG>Module:</STRONG></A> mod_alias<BR>
317 <A
318  HREF="directive-dict.html#Compatibility"
319  REL="Help"
320 ><STRONG>Compatibility:</STRONG></A> This directive is only available in 1.2
321 </P>
322 <P>
323 This directive makes the client know that the Redirect is permanent
324 (status 301). Exactly equivalent to <CODE>Redirect permanent</CODE>.
325 </P>
326 <HR>
327
328 <H2><A NAME="scriptalias">ScriptAlias directive</A></H2>
329 <P>
330 <!--%plaintext &lt;?INDEX {\tt ScriptAlias} directive&gt; -->
331 <A
332  HREF="directive-dict.html#Syntax"
333  REL="Help"
334 ><STRONG>Syntax:</STRONG></A> ScriptAlias <EM>url-path directory-filename</EM>
335 <BR>
336 <A
337  HREF="directive-dict.html#Context"
338  REL="Help"
339 ><STRONG>Context:</STRONG></A> server config, virtual host<BR>
340 <A
341  HREF="directive-dict.html#Status"
342  REL="Help"
343 ><STRONG>Status:</STRONG></A> Base<BR>
344 <A
345  HREF="directive-dict.html#Module"
346  REL="Help"
347 ><STRONG>Module:</STRONG></A> mod_alias
348 </P>
349 <P>
350 The ScriptAlias directive has the same behavior as the
351 <A HREF="#alias">Alias</A> directive, except that in addition it
352 marks the target directory as containing CGI scripts.
353 URLs with a (%-decoded) path beginning with <EM>url-path</EM> will be
354 mapped to scripts beginning with <EM>directory-filename</EM>.
355 <P>
356 Example:
357 </P>
358 <BLOCKQUOTE><CODE>ScriptAlias /cgi-bin/ /web/cgi-bin/</CODE></BLOCKQUOTE>
359 <P>
360 A request for http://myserver/cgi-bin/foo would cause the server to
361 run the script /web/cgi-bin/foo.
362 </P>
363
364 <HR>
365
366 <H2><A NAME="scriptaliasmatch">ScriptAliasMatch</A></H2>
367 <P>
368 <A
369  HREF="directive-dict.html#Syntax"
370  REL="Help"
371 ><STRONG>Syntax:</STRONG></A> ScriptAliasMatch
372  <EM>regex directory-filename</EM><BR>
373 <A
374  HREF="directive-dict.html#Context"
375  REL="Help"
376 ><STRONG>Context:</STRONG></A> server config, virtual host<BR>
377 <A
378  HREF="directive-dict.html#Status"
379  REL="Help"
380 ><STRONG>Status:</STRONG></A> Base<BR>
381 <A
382  HREF="directive-dict.html#Module"
383  REL="Help"
384 ><STRONG>Module:</STRONG></A> mod_alias<BR>
385 <A
386  HREF="directive-dict.html#Compatibility"
387  REL="Help"
388 ><STRONG>Compatibility:</STRONG></A> Available in Apache 1.3 and later
389 </P>
390
391 <P>This directive is equivalent to <A HREF="#scriptalias">ScriptAlias</A>, but
392 makes use of standard regular expressions, instead of simple prefix
393 matching. The supplied regular expression is matched against the URL,
394 and if it matches, the server will substitute any parenthesized
395 matches into the given string and use it as a filename. For example,
396 to activate the standard <CODE>/cgi-bin</CODE>, one might use:
397 <PRE>
398     ScriptAliasMatch ^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
399 </PRE>
400 </P>
401
402 <!--#include virtual="footer.html" -->
403 </BODY>
404 </HTML>