]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_alias.html.en
Update transformations. Nothing to see here.
[apache] / docs / manual / mod / mod_alias.html.en
1 <html xmlns="http://www.w3.org/TR/xhtml1/strict"><head><!--
2         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
3               This file is generated from xml source: DO NOT EDIT
4         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5       --><title>mod_alias - Apache HTTP Server</title><link href="../style/manual.css" type="text/css" rel="stylesheet"/></head><body><blockquote><div align="center"><img src="../images/sub.gif" alt="[APACHE DOCUMENTATION]"/><h3>Apache HTTP Server Version 2.0</h3></div><h1 align="center">Apache Module mod_alias</h1><table cellspacing="1" cellpadding="0" bgcolor="#cccccc"><tr><td><table bgcolor="#ffffff"><tr><td nowrap="nowrap" valign="top"><span class="help">Description:
6                       </span></td><td>Provides for mapping different parts of the host
7     filesystem in the document tree and for URL redirection</td></tr><tr><td nowrap="nowrap"><a href="module-dict.html#Status" class="help">Status:
8                       </a></td><td>Base</td></tr><tr><td nowrap="nowrap"><a href="module-dict.html#ModuleIdentifier" class="help">Module&nbsp;Identifier:
9                         </a></td><td>alias_module</td></tr></table></td></tr></table><h2>Summary</h2>
10     <p>The directives contained in this module allow for manipulation
11     and control of URLs as requests arrive at the server. The
12     <a href="#alias" class="directive"><code class="directive">Alias</code></a> and <a href="#scriptalias" class="directive"><code class="directive">ScriptAlias</code></a> directives are used to
13     map between URLs and filesystem paths.  This allows for content
14     which is not directly under the <a href="../mod/core.html#documentroot" class="directive"><code class="directive">DocumentRoot</code></a> served as part of the web
15     document tree. The <a href="#scriptalias" class="directive"><code class="directive">ScriptAlias</code></a> directive has the
16     additional effect of marking the target directory as containing
17     only CGI scripts.</p>
18
19     <p>The <a href="#redirect" class="directive"><code class="directive">Redirect</code></a>
20     directives are used to instruct clients to make a new request with
21     a different URL. They are often used when a resource has moved to
22     a new location.</p>
23 <h2>Directives</h2><ul><li><a href="#alias">Alias</a></li><li><a href="#aliasmatch">AliasMatch</a></li><li><a href="#redirect">Redirect</a></li><li><a href="#redirectmatch">RedirectMatch</a></li><li><a href="#redirectpermanent">RedirectPermanent</a></li><li><a href="#redirecttemp">RedirectTemp</a></li><li><a href="#scriptalias">ScriptAlias</a></li><li><a href="#scriptaliasmatch">ScriptAliasMatch</a></li></ul><p><strong>See also </strong></p><ul><li><code><a href="../mod/mod_rewrite.html">mod_rewrite</a></code></li><li><a href="../urlmapping.html">Mapping URLs to the filesystem</a></li></ul><hr/><h2><a name="Alias">Alias</a> <a name="alias">Directive</a></h2><table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc"><tr><td><table bgcolor="#ffffff"><tr><td nowrap="nowrap"><strong>Description: 
24                   </strong></td><td>Maps URLs to filesystem locations</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Syntax" class="help">Syntax:
25                   </a></td><td> Alias <em>URL-path
26     file-path</em>|<em>directory-path</em></td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Context" class="help">Context:
27                   </a></td><td>server config, virtual host</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Status" class="help">Status:
28                   </a></td><td>Base</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Module" class="help">Module:
29                   </a></td><td>mod_alias</td></tr></table></td></tr></table>
30
31     <p>The <code class="directive">Alias</code> directive allows documents to
32     be stored in the local filesystem other than under the 
33     <a href="../mod/core.html#documentroot" class="directive"><code class="directive">DocumentRoot</code></a>. URLs with a
34     (%-decoded) path beginning with <em>url-path</em> will be mapped
35     to local files beginning with <em>directory-filename</em>.</p>
36
37     <p>Example:</p>
38
39 <blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>Alias /image /ftp/pub/image</code></td></tr></table></blockquote>
40
41     <p>A request for http://myserver/image/foo.gif would cause the
42     server to return the file /ftp/pub/image/foo.gif.</p>
43
44     <p>Note that if you include a trailing / on the
45     <em>url-path</em> then the server will require a trailing / in
46     order to expand the alias. That is, if you use <code>Alias
47     /icons/ /usr/local/apache/icons/</code> then the url
48     <code>/icons</code> will not be aliased.</p>
49
50     <p>Note that you may need to specify additional <a href="../mod/core.html#<directory>" class="directive"><code class="directive">&lt;Directory&gt;</code></a> sections which cover
51     the <em>destination</em> of aliases.  Aliasing occurs before
52     <a href="../mod/core.html#<directory>" class="directive"><code class="directive">&lt;Directory&gt;</code></a> sections
53     are checked, so only the destination of aliases are affected.
54     (Note however <a href="../mod/core.html#<location>" class="directive"><code class="directive">&lt;Location&gt;</code></a>
55     sections are run through once before aliases are performed, so
56     they will apply.)</p>
57
58 <hr/><h2><a name="AliasMatch">AliasMatch</a> <a name="aliasmatch">Directive</a></h2><table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc"><tr><td><table bgcolor="#ffffff"><tr><td nowrap="nowrap"><strong>Description: 
59                   </strong></td><td>Maps URLs to filesystem locations using regular 
60 expressions</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Syntax" class="help">Syntax:
61                   </a></td><td>AliasMatch <em>regex
62     file-path</em>|<em>directory-path</em></td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Context" class="help">Context:
63                   </a></td><td>server config, virtual host</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Status" class="help">Status:
64                   </a></td><td>Base</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Module" class="help">Module:
65                   </a></td><td>mod_alias</td></tr></table></td></tr></table>
66     <p>This directive is equivalent to <a href="#alias" class="directive"><code class="directive">Alias</code></a>, but makes use of standard
67     regular expressions, instead of simple prefix matching. The
68     supplied regular expression is matched against the URL-path, and
69     if it matches, the server will substitute any parenthesized
70     matches into the given string and use it as a filename. For
71     example, to activate the <code>/icons</code> directory, one might
72     use:</p>
73 <blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
74     AliasMatch ^/icons(.*) /usr/local/apache/icons$1
75 </code></td></tr></table></blockquote>
76 <hr/><h2><a name="Redirect">Redirect</a> <a name="redirect">Directive</a></h2><table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc"><tr><td><table bgcolor="#ffffff"><tr><td nowrap="nowrap"><strong>Description: 
77                   </strong></td><td>Sends an external redirect asking the client to fetch
78 a different URL</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Syntax" class="help">Syntax:
79                   </a></td><td>Redirect [<em>status</em>] <em>URL-path URL</em></td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Context" class="help">Context:
80                   </a></td><td>server config, virtual host, directory, .htaccess</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Override" class="help">Override:
81                     </a></td><td>FileInfo</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Status" class="help">Status:
82                   </a></td><td>Base</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Module" class="help">Module:
83                   </a></td><td>mod_alias</td></tr></table></td></tr></table>
84     <p>The Redirect directive maps an old URL into a new one. The
85     new URL is returned to the client which attempts to fetch it
86     again with the new address. <em>URL-path</em> a (%-decoded)
87     path; any requests for documents beginning with this path will
88     be returned a redirect error to a new (%-encoded) URL beginning
89     with <em>URL</em>.</p>
90
91     <p>Example:</p>
92
93 <blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>Redirect /service http://foo2.bar.com/service</code></td></tr></table></blockquote>
94
95     <p>If the client requests http://myserver/service/foo.txt, it
96     will be told to access http://foo2.bar.com/service/foo.txt
97     instead.</p>
98
99 <blockquote><table><tr><td bgcolor="#e0e5f5"><p align="center"><strong>Note</strong></p> <p>Redirect directives take precedence over
100 Alias and ScriptAlias directives, irrespective of their ordering in
101 the configuration file. Also, <em>URL-path</em> must be an absolute
102 path, not a relative path, even when used with .htaccess files or
103 inside of <a href="../mod/core.html#<directory>" class="directive"><code class="directive">&lt;Directory&gt;</code></a>
104 sections.</p></td></tr></table></blockquote>
105
106     <p>If no <em>status</em> argument is given, the redirect will
107     be "temporary" (HTTP status 302). This indicates to the client
108     that the resource has moved temporarily. The <em>status</em>
109     argument can be used to return other HTTP status codes:</p>
110
111     <dl>
112       <dt>permanent</dt>
113
114       <dd>Returns a permanent redirect status (301) indicating that
115       the resource has moved permanently.</dd>
116
117       <dt>temp</dt>
118
119       <dd>Returns a temporary redirect status (302). This is the
120       default.</dd>
121
122       <dt>seeother</dt>
123
124       <dd>Returns a "See Other" status (303) indicating that the
125       resource has been replaced.</dd>
126
127       <dt>gone</dt>
128
129       <dd>Returns a "Gone" status (410) indicating that the
130       resource has been permanently removed. When this status is
131       used the <em>url</em> argument should be omitted.</dd>
132     </dl>
133
134     <p>Other status codes can be returned by giving the numeric
135     status code as the value of <em>status</em>. If the status is
136     between 300 and 399, the <em>url</em> argument must be present,
137     otherwise it must be omitted. Note that the status must be
138     known to the Apache code (see the function
139     <code>send_error_response</code> in http_protocol.c).</p>
140
141     <p>Example:</p>
142
143     <blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
144         Redirect permanent /one http://example.com/two<br>
145         Redirect 303 /three http://example.com/other
146     </code></td></tr></table></blockquote>
147
148 <hr/><h2><a name="RedirectMatch">RedirectMatch</a> <a name="redirectmatch">Directive</a></h2><table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc"><tr><td><table bgcolor="#ffffff"><tr><td nowrap="nowrap"><strong>Description: 
149                   </strong></td><td>Sends an external redirect asking the client to fetch
150 a different URL based on a regular expression match of the 
151 current URL</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Syntax" class="help">Syntax:
152                   </a></td><td>RedirectMatch [<em>status</em>] <em>regex URL</em></td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Context" class="help">Context:
153                   </a></td><td>server config, virtual host, directory, .htaccess</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Override" class="help">Override:
154                     </a></td><td>FileInfo</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Status" class="help">Status:
155                   </a></td><td>Base</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Module" class="help">Module:
156                   </a></td><td>mod_alias</td></tr></table></td></tr></table>
157     <p>This directive is equivalent to <a href="#redirect" class="directive"><code class="directive">Redirect</code></a>, but makes use of standard
158     regular expressions, instead of simple prefix matching. The
159     supplied regular expression is matched against the URL-path, and
160     if it matches, the server will substitute any parenthesized
161     matches into the given string and use it as a filename. For
162     example, to redirect all GIF files to like-named JPEG files on
163     another server, one might use:</p>
164 <blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
165     RedirectMatch (.*)\.gif$ http://www.anotherserver.com$1.jpg
166 </code></td></tr></table></blockquote>
167 <hr/><h2><a name="RedirectPermanent">RedirectPermanent</a> <a name="redirectpermanent">Directive</a></h2><table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc"><tr><td><table bgcolor="#ffffff"><tr><td nowrap="nowrap"><strong>Description: 
168                   </strong></td><td>Sends an external permanent redirect asking the client to fetch
169 a different URL</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Syntax" class="help">Syntax:
170                   </a></td><td>RedirectPermanent <em>URL-path URL</em></td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Context" class="help">Context:
171                   </a></td><td>server config, virtual host, directory, .htaccess</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Override" class="help">Override:
172                     </a></td><td>FileInfo</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Status" class="help">Status:
173                   </a></td><td>Base</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Module" class="help">Module:
174                   </a></td><td>mod_alias</td></tr></table></td></tr></table>
175     <p>This directive makes the client know that the Redirect is
176     permanent (status 301). Exactly equivalent to <code>Redirect
177     permanent</code>.</p>
178 <hr/><h2><a name="RedirectTemp">RedirectTemp</a> <a name="redirecttemp">Directive</a></h2><table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc"><tr><td><table bgcolor="#ffffff"><tr><td nowrap="nowrap"><strong>Description: 
179                   </strong></td><td>Sends an external temporary redirect asking the client to fetch
180 a different URL</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Syntax" class="help">Syntax:
181                   </a></td><td>RedirectTemp <em>URL-path URL</em></td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Context" class="help">Context:
182                   </a></td><td>server config, virtual host, directory, .htaccess</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Override" class="help">Override:
183                     </a></td><td>FileInfo</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Status" class="help">Status:
184                   </a></td><td>Base</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Module" class="help">Module:
185                   </a></td><td>mod_alias</td></tr></table></td></tr></table>
186     <p>This directive makes the client know that the Redirect is
187     only temporary (status 302). Exactly equivalent to
188     <code>Redirect temp</code>.</p>
189 <hr/><h2><a name="ScriptAlias">ScriptAlias</a> <a name="scriptalias">Directive</a></h2><table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc"><tr><td><table bgcolor="#ffffff"><tr><td nowrap="nowrap"><strong>Description: 
190                   </strong></td><td>Maps a URL to a filesystem location and designates the
191 target as a CGI script</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Syntax" class="help">Syntax:
192                   </a></td><td>ScriptAlias 
193 <em>URL-path file-path</em>|<em>directory-path</em></td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Context" class="help">Context:
194                   </a></td><td>server config, virtual host</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Status" class="help">Status:
195                   </a></td><td>Base</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Module" class="help">Module:
196                   </a></td><td>mod_alias</td></tr></table></td></tr></table>
197     <p>The <code class="directive">ScriptAlias</code> directive has the same
198     behavior as the <a href="#alias" class="directive"><code class="directive">Alias</code></a>
199     directive, except that in addition it marks the target directory
200     as containing CGI scripts that will be processed by <code><a href="../mod/mod_cgi.html">mod_cgi</a></code>'s cgi-script handler. URLs with a
201     (%-decoded) path beginning with <em>URL-path</em> will be mapped
202     to scripts beginning with the second argument which is a full
203     pathname in the local filesystem.</p>
204
205     <p>Example:</p>
206
207 <blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>ScriptAlias /cgi-bin/ /web/cgi-bin/</code></td></tr></table></blockquote>
208
209     <p>A request for <code>http://myserver/cgi-bin/foo</code> would cause the
210     server to run the script <code>/web/cgi-bin/foo</code>.</p>
211 <hr/><h2><a name="ScriptAliasMatch">ScriptAliasMatch</a> <a name="scriptaliasmatch">Directive</a></h2><table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc"><tr><td><table bgcolor="#ffffff"><tr><td nowrap="nowrap"><strong>Description: 
212                   </strong></td><td>Maps a URL to a filesystem location using a regular expression
213 and designates the target as a CGI script</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Syntax" class="help">Syntax:
214                   </a></td><td>ScriptAliasMatch
215 <em>regex file-path</em>|<em>directory-path</em></td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Context" class="help">Context:
216                   </a></td><td>server config, virtual host</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Status" class="help">Status:
217                   </a></td><td>Base</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Module" class="help">Module:
218                   </a></td><td>mod_alias</td></tr></table></td></tr></table>
219     <p>This directive is equivalent to <a href="#scriptalias" class="directive"><code class="directive">ScriptAlias</code></a>, but makes use of standard
220     regular expressions, instead of simple prefix matching. The
221     supplied regular expression is matched against the URL-path,
222     and if it matches, the server will substitute any parenthesized
223     matches into the given string and use it as a filename. For
224     example, to activate the standard <code>/cgi-bin</code>, one
225     might use:</p>
226 <blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
227     ScriptAliasMatch ^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
228 </code></td></tr></table></blockquote>
229 <hr/></blockquote><h3 align="center">Apache HTTP Server Version 2.0</h3><a href="./"><img src="../images/index.gif" alt="Index"/></a><a href="../"><img src="../images/home.gif" alt="Home"/></a></body></html>