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.1</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-project/">Documentation</a> > <a href="../">Version 2.1</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></p>
27 <table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Provides for mapping different parts of the host
28 filesystem in the document tree and for URL redirection</td></tr>
29 <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Base</td></tr>
30 <tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>alias_module</td></tr>
31 <tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>mod_alias.c</td></tr></table>
34 <p>The directives contained in this module allow for manipulation
35 and control of URLs as requests arrive at the server. The
36 <code class="directive"><a href="#alias">Alias</a></code> and <code class="directive"><a href="#scriptalias">ScriptAlias</a></code> directives are used to
37 map between URLs and filesystem paths. This allows for content
38 which is not directly under the <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code> served as part of the web
39 document tree. The <code class="directive"><a href="#scriptalias">ScriptAlias</a></code> directive has the
40 additional effect of marking the target directory as containing
43 <p>The <code class="directive"><a href="#redirect">Redirect</a></code>
44 directives are used to instruct clients to make a new request with
45 a different URL. They are often used when a resource has moved to
48 <div id="quickview"><h3 class="directives">Directives</h3>
50 <li><img alt="" src="../images/down.gif" /> <a href="#alias">Alias</a></li>
51 <li><img alt="" src="../images/down.gif" /> <a href="#aliasmatch">AliasMatch</a></li>
52 <li><img alt="" src="../images/down.gif" /> <a href="#redirect">Redirect</a></li>
53 <li><img alt="" src="../images/down.gif" /> <a href="#redirectmatch">RedirectMatch</a></li>
54 <li><img alt="" src="../images/down.gif" /> <a href="#redirectpermanent">RedirectPermanent</a></li>
55 <li><img alt="" src="../images/down.gif" /> <a href="#redirecttemp">RedirectTemp</a></li>
56 <li><img alt="" src="../images/down.gif" /> <a href="#scriptalias">ScriptAlias</a></li>
57 <li><img alt="" src="../images/down.gif" /> <a href="#scriptaliasmatch">ScriptAliasMatch</a></li>
61 <li><code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code></li>
62 <li><a href="../urlmapping.html">Mapping URLs to the filesystem</a></li>
65 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
66 <div class="directive-section"><h2><a name="Alias" id="Alias">Alias</a> <a name="alias" id="alias">Directive</a></h2>
67 <table class="directive">
68 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps URLs to filesystem locations</td></tr>
69 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>Alias <var>URL-path</var>
70 <var>file-path</var>|<var>directory-path</var></code></td></tr>
71 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
72 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
73 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
76 <p>The <code class="directive">Alias</code> directive allows documents to
77 be stored in the local filesystem other than under the
78 <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code>. URLs with a
79 (%-decoded) path beginning with <var>url-path</var> will be mapped
80 to local files beginning with <var>directory-path</var>.</p>
82 <div class="example"><h3>Example:</h3><p><code>
83 Alias /image /ftp/pub/image
86 <p>A request for http://myserver/image/foo.gif would cause the
87 server to return the file /ftp/pub/image/foo.gif.</p>
89 <p>Note that if you include a trailing / on the
90 <var>url-path</var> then the server will require a trailing / in
91 order to expand the alias. That is, if you use <code>Alias
92 /icons/ /usr/local/apache/icons/</code> then the url
93 <code>/icons</code> will not be aliased.</p>
95 <p>Note that you may need to specify additional <code class="directive"><a href="../mod/core.html#directory"><Directory></a></code> sections which
96 cover the <em>destination</em> of aliases. Aliasing occurs before
97 <code class="directive"><a href="../mod/core.html#directory"><Directory></a></code> sections
98 are checked, so only the destination of aliases are affected.
99 (Note however <code class="directive"><a href="../mod/core.html#location"><Location></a></code>
100 sections are run through once before aliases are performed, so
101 they will apply.)</p>
103 <p>In particular, if you are creating an <code>Alias</code> to a
104 directory outside of your <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code>, you may need to explicitly
105 permit access to the target directory.</p>
107 <div class="example"><h3>Example:</h3><p><code>
108 Alias /image /ftp/pub/image<br />
109 <Directory /ftp/pub/image><br />
110 <span class="indent">
111 Order allow,deny<br />
119 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
120 <div class="directive-section"><h2><a name="AliasMatch" id="AliasMatch">AliasMatch</a> <a name="aliasmatch" id="aliasmatch">Directive</a></h2>
121 <table class="directive">
122 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps URLs to filesystem locations using regular
123 expressions</td></tr>
124 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>AliasMatch <var>regex</var>
125 <var>file-path</var>|<var>directory-path</var></code></td></tr>
126 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
127 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
128 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
130 <p>This directive is equivalent to <code class="directive"><a href="#alias">Alias</a></code>, but makes use of standard
131 regular expressions, instead of simple prefix matching. The
132 supplied regular expression is matched against the URL-path, and
133 if it matches, the server will substitute any parenthesized
134 matches into the given string and use it as a filename. For
135 example, to activate the <code>/icons</code> directory, one might
138 <div class="example"><p><code>
139 AliasMatch ^/icons(.*) /usr/local/apache/icons$1
143 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
144 <div class="directive-section"><h2><a name="Redirect" id="Redirect">Redirect</a> <a name="redirect" id="redirect">Directive</a></h2>
145 <table class="directive">
146 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sends an external redirect asking the client to fetch
147 a different URL</td></tr>
148 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>Redirect [<var>status</var>] <var>URL-path</var>
149 <var>URL</var></code></td></tr>
150 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
151 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
152 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
153 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
155 <p>The Redirect directive maps an old URL into a new one. The
156 new URL is returned to the client which attempts to fetch it
157 again with the new address. <var>URL-path</var> a (%-decoded)
158 path; any requests for documents beginning with this path will
159 be returned a redirect error to a new (%-encoded) URL beginning
160 with <var>URL</var>.</p>
162 <div class="example"><h3>Example:</h3><p><code>
163 Redirect /service http://foo2.bar.com/service
166 <p>If the client requests http://myserver/service/foo.txt, it
167 will be told to access http://foo2.bar.com/service/foo.txt
170 <div class="note"><h3>Note</h3> <p>Redirect directives take precedence over
171 Alias and ScriptAlias directives, irrespective of their ordering in
172 the configuration file. Also, <var>URL-path</var> must be a fully
173 qualified URL, not a relative path, even when used with .htaccess files or
174 inside of <code class="directive"><a href="../mod/core.html#directory"><Directory></a></code>
177 <p>If no <var>status</var> argument is given, the redirect will
178 be "temporary" (HTTP status 302). This indicates to the client
179 that the resource has moved temporarily. The <var>status</var>
180 argument can be used to return other HTTP status codes:</p>
185 <dd>Returns a permanent redirect status (301) indicating that
186 the resource has moved permanently.</dd>
190 <dd>Returns a temporary redirect status (302). This is the
195 <dd>Returns a "See Other" status (303) indicating that the
196 resource has been replaced.</dd>
200 <dd>Returns a "Gone" status (410) indicating that the
201 resource has been permanently removed. When this status is
202 used the <var>URL</var> argument should be omitted.</dd>
205 <p>Other status codes can be returned by giving the numeric
206 status code as the value of <var>status</var>. If the status is
207 between 300 and 399, the <var>URL</var> argument must be present,
208 otherwise it must be omitted. Note that the status must be
209 known to the Apache code (see the function
210 <code>send_error_response</code> in http_protocol.c).</p>
212 <div class="example"><h3>Example:</h3><p><code>
213 Redirect permanent /one http://example.com/two<br />
214 Redirect 303 /three http://example.com/other
219 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
220 <div class="directive-section"><h2><a name="RedirectMatch" id="RedirectMatch">RedirectMatch</a> <a name="redirectmatch" id="redirectmatch">Directive</a></h2>
221 <table class="directive">
222 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sends an external redirect based on a regular expression match
223 of the current URL</td></tr>
224 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RedirectMatch [<var>status</var>] <var>regex</var>
225 <var>URL</var></code></td></tr>
226 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
227 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
228 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
229 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
231 <p>This directive is equivalent to <code class="directive"><a href="#redirect">Redirect</a></code>, but makes use of standard
232 regular expressions, instead of simple prefix matching. The
233 supplied regular expression is matched against the URL-path, and
234 if it matches, the server will substitute any parenthesized
235 matches into the given string and use it as a filename. For
236 example, to redirect all GIF files to like-named JPEG files on
237 another server, one might use:</p>
239 <div class="example"><p><code>
240 RedirectMatch (.*)\.gif$ http://www.anotherserver.com$1.jpg
244 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
245 <div class="directive-section"><h2><a name="RedirectPermanent" id="RedirectPermanent">RedirectPermanent</a> <a name="redirectpermanent" id="redirectpermanent">Directive</a></h2>
246 <table class="directive">
247 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sends an external permanent redirect asking the client to fetch
248 a different URL</td></tr>
249 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RedirectPermanent <var>URL-path</var> <var>URL</var></code></td></tr>
250 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
251 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
252 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
253 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
255 <p>This directive makes the client know that the Redirect is
256 permanent (status 301). Exactly equivalent to <code>Redirect
257 permanent</code>.</p>
260 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
261 <div class="directive-section"><h2><a name="RedirectTemp" id="RedirectTemp">RedirectTemp</a> <a name="redirecttemp" id="redirecttemp">Directive</a></h2>
262 <table class="directive">
263 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sends an external temporary redirect asking the client to fetch
264 a different URL</td></tr>
265 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RedirectTemp <var>URL-path</var> <var>URL</var></code></td></tr>
266 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
267 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
268 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
269 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
271 <p>This directive makes the client know that the Redirect is
272 only temporary (status 302). Exactly equivalent to
273 <code>Redirect temp</code>.</p>
276 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
277 <div class="directive-section"><h2><a name="ScriptAlias" id="ScriptAlias">ScriptAlias</a> <a name="scriptalias" id="scriptalias">Directive</a></h2>
278 <table class="directive">
279 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps a URL to a filesystem location and designates the
280 target as a CGI script</td></tr>
281 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ScriptAlias <var>URL-path</var>
282 <var>file-path</var>|<var>directory-path</var></code></td></tr>
283 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
284 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
285 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
287 <p>The <code class="directive">ScriptAlias</code> directive has the same
288 behavior as the <code class="directive"><a href="#alias">Alias</a></code>
289 directive, except that in addition it marks the target directory
290 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
291 (%-decoded) path beginning with <var>URL-path</var> will be mapped
292 to scripts beginning with the second argument which is a full
293 pathname in the local filesystem.</p>
295 <div class="example"><h3>Example:</h3><p><code>
296 ScriptAlias /cgi-bin/ /web/cgi-bin/
299 <p>A request for <code>http://myserver/cgi-bin/foo</code> would cause the
300 server to run the script <code>/web/cgi-bin/foo</code>.</p>
303 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
304 <div class="directive-section"><h2><a name="ScriptAliasMatch" id="ScriptAliasMatch">ScriptAliasMatch</a> <a name="scriptaliasmatch" id="scriptaliasmatch">Directive</a></h2>
305 <table class="directive">
306 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps a URL to a filesystem location using a regular expression
307 and designates the target as a CGI script</td></tr>
308 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ScriptAliasMatch <var>regex</var>
309 <var>file-path</var>|<var>directory-path</var></code></td></tr>
310 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
311 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
312 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
314 <p>This directive is equivalent to <code class="directive"><a href="#scriptalias">ScriptAlias</a></code>, but makes use of standard
315 regular expressions, instead of simple prefix matching. The
316 supplied regular expression is matched against the URL-path,
317 and if it matches, the server will substitute any parenthesized
318 matches into the given string and use it as a filename. For
319 example, to activate the standard <code>/cgi-bin</code>, one
322 <div class="example"><p><code>
323 ScriptAliasMatch ^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
328 <div class="bottomlang">
329 <p><span>Available Languages: </span><a href="../en/mod/mod_alias.html" title="English"> en </a> |
330 <a href="../ja/mod/mod_alias.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a></p>
331 </div><div id="footer">
332 <p class="apache">Copyright 1999-2004 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>
333 <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>