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 <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type" />
6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7 This file is generated from xml source: DO NOT EDIT
8 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
10 <title>mod_alias - Apache HTTP Server Version 2.5</title>
11 <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
12 <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
13 <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" />
14 <script src="../style/scripts/prettify.min.js" type="text/javascript">
17 <link href="../images/favicon.ico" rel="shortcut icon" /></head>
19 <div id="page-header">
20 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/quickreference.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
21 <p class="apache">Apache HTTP Server Version 2.5</p>
22 <img alt="" src="../images/feather.png" /></div>
23 <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div>
25 <a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.5</a> > <a href="./">Modules</a></div>
26 <div id="page-content">
27 <div id="preamble"><h1>Apache Module mod_alias</h1>
29 <p><span>Available Languages: </span><a href="../en/mod/mod_alias.html" title="English"> en </a> |
30 <a href="../fr/mod/mod_alias.html" hreflang="fr" rel="alternate" title="Français"> fr </a> |
31 <a href="../ja/mod/mod_alias.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
32 <a href="../ko/mod/mod_alias.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> |
33 <a href="../tr/mod/mod_alias.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p>
35 <table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Provides for mapping different parts of the host
36 filesystem in the document tree and for URL redirection</td></tr>
37 <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Base</td></tr>
38 <tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>alias_module</td></tr>
39 <tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>mod_alias.c</td></tr></table>
42 <p>The directives contained in this module allow for manipulation
43 and control of URLs as requests arrive at the server. The
44 <code class="directive"><a href="#alias">Alias</a></code> and <code class="directive"><a href="#scriptalias">ScriptAlias</a></code> directives are used to
45 map between URLs and filesystem paths. This allows for content
46 which is not directly under the <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code> served as part of the web
47 document tree. The <code class="directive"><a href="#scriptalias">ScriptAlias</a></code> directive has the
48 additional effect of marking the target directory as containing
51 <p>The <code class="directive"><a href="#redirect">Redirect</a></code>
52 directives are used to instruct clients to make a new request with
53 a different URL. They are often used when a resource has moved to
56 <p>When the <code class="directive"><a href="#alias">Alias</a></code>,
57 <code class="directive"><a href="#scriptalias">ScriptAlias</a></code> and
58 <code class="directive"><a href="#redirect">Redirect</a></code> directives are used
59 within a <code class="directive"><a href="../mod/core.html#location"><Location></a></code>
60 or <code class="directive"><a href="../mod/core.html#locationmatch"><LocationMatch></a></code>
61 section, <a href="../expr.html">expression syntax</a> can be used
62 to manipulate the destination path or URL.
65 <p><code class="module"><a href="../mod/mod_alias.html">mod_alias</a></code> is designed to handle simple URL
66 manipulation tasks. For more complicated tasks such as
67 manipulating the query string, use the tools provided by
68 <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>.</p>
71 <div id="quickview"><h3>Topics</h3>
73 <li><img alt="" src="../images/down.gif" /> <a href="#order">Order of Processing</a></li>
74 </ul><h3 class="directives">Directives</h3>
76 <li><img alt="" src="../images/down.gif" /> <a href="#alias">Alias</a></li>
77 <li><img alt="" src="../images/down.gif" /> <a href="#aliasmatch">AliasMatch</a></li>
78 <li><img alt="" src="../images/down.gif" /> <a href="#redirect">Redirect</a></li>
79 <li><img alt="" src="../images/down.gif" /> <a href="#redirectmatch">RedirectMatch</a></li>
80 <li><img alt="" src="../images/down.gif" /> <a href="#redirectpermanent">RedirectPermanent</a></li>
81 <li><img alt="" src="../images/down.gif" /> <a href="#redirecttemp">RedirectTemp</a></li>
82 <li><img alt="" src="../images/down.gif" /> <a href="#scriptalias">ScriptAlias</a></li>
83 <li><img alt="" src="../images/down.gif" /> <a href="#scriptaliasmatch">ScriptAliasMatch</a></li>
85 <h3>Bugfix checklist</h3><ul class="seealso"><li><a href="https://www.apache.org/dist/httpd/CHANGES_2.4">httpd changelog</a></li><li><a href="https://bz.apache.org/bugzilla/buglist.cgi?bug_status=__open__&list_id=144532&product=Apache%20httpd-2&query_format=specific&order=changeddate%20DESC%2Cpriority%2Cbug_severity&component=mod_alias">Known issues</a></li><li><a href="https://bz.apache.org/bugzilla/enter_bug.cgi?product=Apache%20httpd-2&component=mod_alias">Report a bug</a></li></ul><h3>See also</h3>
87 <li><code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code></li>
88 <li><a href="../urlmapping.html">Mapping URLs to the filesystem</a></li>
89 </ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
90 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
92 <h2><a name="order" id="order">Order of Processing</a></h2>
94 <p>Aliases and Redirects occurring in different contexts are processed
95 like other directives according to standard <a href="../sections.html#mergin">merging rules</a>. But when multiple
96 Aliases or Redirects occur in the same context (for example, in the
97 same <code class="directive"><a href="../mod/core.html#virtualhost"><VirtualHost></a></code>
98 section) they are processed in a particular order.</p>
100 <p>First, all Redirects are processed before Aliases are processed,
101 and therefore a request that matches a <code class="directive"><a href="#redirect">Redirect</a></code> or <code class="directive"><a href="#redirectmatch">RedirectMatch</a></code> will never have Aliases
102 applied. Second, the Aliases and Redirects are processed in the order
103 they appear in the configuration files, with the first match taking
106 <p>For this reason, when two or more of these directives apply to the
107 same sub-path, you must list the most specific path first in order for
108 all the directives to have an effect. For example, the following
109 configuration will work as expected:</p>
111 <pre class="prettyprint lang-config">Alias "/foo/bar" "/baz"
112 Alias "/foo" "/gaq"</pre>
115 <p>But if the above two directives were reversed in order, the
116 <code>/foo</code> <code class="directive"><a href="#alias">Alias</a></code>
117 would always match before the <code>/foo/bar</code> <code class="directive"><a href="#alias">Alias</a></code>, so the latter directive would be
120 <p>When the <code class="directive"><a href="#alias">Alias</a></code>,
121 <code class="directive"><a href="#scriptalias">ScriptAlias</a></code> and
122 <code class="directive"><a href="#redirect">Redirect</a></code> directives are used
123 within a <code class="directive"><a href="../mod/core.html#location"><Location></a></code>
124 or <code class="directive"><a href="../mod/core.html#locationmatch"><LocationMatch></a></code>
125 section, these directives will take precedence over any globally
126 defined <code class="directive"><a href="#alias">Alias</a></code>,
127 <code class="directive"><a href="#scriptalias">ScriptAlias</a></code> and
128 <code class="directive"><a href="#redirect">Redirect</a></code> directives.</p>
131 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
132 <div class="directive-section"><h2><a name="Alias" id="Alias">Alias</a> <a name="alias" id="alias">Directive</a></h2>
133 <table class="directive">
134 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps URLs to filesystem locations</td></tr>
135 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>Alias [<var>URL-path</var>]
136 <var>file-path</var>|<var>directory-path</var></code></td></tr>
137 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory</td></tr>
138 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
139 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
142 <p>The <code class="directive">Alias</code> directive allows documents to
143 be stored in the local filesystem other than under the
144 <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code>. URLs with a
145 (%-decoded) path beginning with <var>URL-path</var> will be mapped
146 to local files beginning with <var>directory-path</var>. The
147 <var>URL-path</var> is case-sensitive, even on case-insensitive
150 <pre class="prettyprint lang-config">Alias "/image" "/ftp/pub/image"</pre>
153 <p>A request for <code>http://example.com/image/foo.gif</code> would cause
154 the server to return the file <code>/ftp/pub/image/foo.gif</code>. Only
155 complete path segments are matched, so the above alias would not match a
156 request for <code>http://example.com/imagefoo.gif</code>. For more complex
157 matching using regular expressions, see the <code class="directive"><a href="#aliasmatch">AliasMatch</a></code> directive.</p>
159 <p>Note that if you include a trailing / on the
160 <var>URL-path</var> then the server will require a trailing / in
161 order to expand the alias. That is, if you use</p>
163 <pre class="prettyprint lang-config">Alias "/icons/" "/usr/local/apache/icons/"</pre>
166 <p>then the URL <code>/icons</code> will not be aliased, as it lacks
167 that trailing /. Likewise, if you omit the slash on the
168 <var>URL-path</var> then you must also omit it from the
169 <var>file-path</var>.</p>
171 <p>Note that you may need to specify additional <code class="directive"><a href="../mod/core.html#directory"><Directory></a></code> sections which
172 cover the <em>destination</em> of aliases. Aliasing occurs before
173 <code class="directive"><a href="../mod/core.html#directory"><Directory></a></code> sections
174 are checked, so only the destination of aliases are affected.
175 (Note however <code class="directive"><a href="../mod/core.html#location"><Location></a></code>
176 sections are run through once before aliases are performed, so
177 they will apply.)</p>
179 <p>In particular, if you are creating an <code>Alias</code> to a
180 directory outside of your <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code>, you may need to explicitly
181 permit access to the target directory.</p>
183 <pre class="prettyprint lang-config">Alias "/image" "/ftp/pub/image"
184 <Directory "/ftp/pub/image">
186 </Directory></pre>
189 <p>Any number slashes in the <var>URL-path</var> parameter
190 matches any number of slashes in the requested URL-path.</p>
192 <p>If the <code class="directive">Alias</code> directive is used within a
193 <code class="directive"><a href="../mod/core.html#location"><Location></a></code>
194 or <code class="directive"><a href="../mod/core.html#locationmatch"><LocationMatch></a></code>
195 section the URL-path is omitted, and the file-path is interpreted
196 using <a href="../expr.html">expression syntax</a>.<br />
197 This syntax is available in Apache 2.4.19 and later.</p>
199 <pre class="prettyprint lang-config"><Location "/image">
200 Alias "/ftp/pub/image"
202 <LocationMatch "/error/(?<NUMBER>[0-9]+)">
203 Alias "/usr/local/apache/errors/%{env:MATCH_NUMBER}.html"
204 </LocationMatch></pre>
209 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
210 <div class="directive-section"><h2><a name="AliasMatch" id="AliasMatch">AliasMatch</a> <a name="aliasmatch" id="aliasmatch">Directive</a></h2>
211 <table class="directive">
212 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps URLs to filesystem locations using regular
213 expressions</td></tr>
214 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>AliasMatch <var>regex</var>
215 <var>file-path</var>|<var>directory-path</var></code></td></tr>
216 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
217 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
218 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
220 <p>This directive is equivalent to <code class="directive"><a href="#alias">Alias</a></code>, but makes use of
221 <a class="glossarylink" href="../glossary.html#regex" title="see glossary">regular expressions</a>,
222 instead of simple prefix matching. The
223 supplied regular expression is matched against the URL-path, and
224 if it matches, the server will substitute any parenthesized
225 matches into the given string and use it as a filename. For
226 example, to activate the <code>/icons</code> directory, one might
229 <pre class="prettyprint lang-config">AliasMatch "^/icons(/|$)(.*)" "/usr/local/apache/icons$1$2"</pre>
232 <p>The full range of <a class="glossarylink" href="../glossary.html#regex" title="see glossary">regular expression</a>
233 power is available. For example,
234 it is possible to construct an alias with case-insensitive
235 matching of the URL-path:</p>
237 <pre class="prettyprint lang-config">AliasMatch "(?i)^/image(.*)" "/ftp/pub/image$1"</pre>
240 <p>One subtle difference
241 between <code class="directive"><a href="#alias">Alias</a></code>
242 and <code class="directive"><a href="#aliasmatch">AliasMatch</a></code> is
243 that <code class="directive"><a href="#alias">Alias</a></code> will
244 automatically copy any additional part of the URI, past the part
245 that matched, onto the end of the file path on the right side,
246 while <code class="directive"><a href="#aliasmatch">AliasMatch</a></code> will
247 not. This means that in almost all cases, you will want the
248 regular expression to match the entire request URI from beginning
249 to end, and to use substitution on the right side.</p>
251 <p>In other words, just changing
252 <code class="directive"><a href="#alias">Alias</a></code> to
253 <code class="directive"><a href="#aliasmatch">AliasMatch</a></code> will not
254 have the same effect. At a minimum, you need to
255 add <code>^</code> to the beginning of the regular expression
256 and add <code>(.*)$</code> to the end, and add <code>$1</code> to
257 the end of the replacement.</p>
259 <p>For example, suppose you want to replace this with AliasMatch:</p>
261 <pre class="prettyprint lang-config">Alias "/image/" "/ftp/pub/image/"</pre>
264 <p>This is NOT equivalent - don't do this! This will send all
265 requests that have /image/ anywhere in them to /ftp/pub/image/:</p>
267 <pre class="prettyprint lang-config">AliasMatch "/image/" "/ftp/pub/image/"</pre>
270 <p>This is what you need to get the same effect:</p>
272 <pre class="prettyprint lang-config">AliasMatch "^/image/(.*)$" "/ftp/pub/image/$1"</pre>
275 <p>Of course, there's no point in
276 using <code class="directive"><a href="#aliasmatch">AliasMatch</a></code>
277 where <code class="directive"><a href="#alias">Alias</a></code> would
278 work. <code class="directive"><a href="#aliasmatch">AliasMatch</a></code> lets
279 you do more complicated things. For example, you could
280 serve different kinds of files from different directories:</p>
282 <pre class="prettyprint lang-config">AliasMatch "^/image/(.*)\.jpg$" "/files/jpg.images/$1.jpg"
283 AliasMatch "^/image/(.*)\.gif$" "/files/gif.images/$1.gif"</pre>
286 <p>Multiple leading slashes in the requested URL are discarded
287 by the server before directives from this module compares
288 against the requested URL-path.
293 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
294 <div class="directive-section"><h2><a name="Redirect" id="Redirect">Redirect</a> <a name="redirect" id="redirect">Directive</a></h2>
295 <table class="directive">
296 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sends an external redirect asking the client to fetch
297 a different URL</td></tr>
298 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>Redirect [<var>status</var>] [<var>URL-path</var>]
299 <var>URL</var></code></td></tr>
300 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
301 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
302 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
303 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
305 <p>The Redirect directive maps an old URL into a new one by asking
306 the client to refetch the resource at the new location.</p>
308 <p>The old <em>URL-path</em> is a case-sensitive (%-decoded) path
309 beginning with a slash. A relative path is not allowed.</p>
311 <p>The new <em>URL</em> may be either an absolute URL beginning
312 with a scheme and hostname, or a URL-path beginning with a slash.
313 In this latter case the scheme and hostname of the current server will
316 <p>Then any request beginning with <em>URL-Path</em> will return a
317 redirect request to the client at the location of the target
318 <em>URL</em>. Additional path information beyond the matched
319 <em>URL-Path</em> will be appended to the target URL.</p>
321 <pre class="prettyprint lang-config"># Redirect to a URL on a different host
322 Redirect "/service" "http://foo2.example.com/service"
324 # Redirect to a URL on the same host
325 Redirect "/one" "/two"</pre>
328 <p>If the client requests <code>http://example.com/service/foo.txt</code>,
329 it will be told to access
330 <code>http://foo2.example.com/service/foo.txt</code>
331 instead. This includes requests with <code>GET</code> parameters, such as
332 <code>http://example.com/service/foo.pl?q=23&a=42</code>,
333 it will be redirected to
334 <code>http://foo2.example.com/service/foo.pl?q=23&a=42</code>.
335 Note that <code>POST</code>s will be discarded.<br />
336 Only complete path segments are matched, so the above
337 example would not match a request for
338 <code>http://example.com/servicefoo.txt</code>. For more complex matching
339 using the <a href="../expr.html">expression syntax</a>, omit the URL-path
340 argument as described below. Alternatively, for matching using regular
341 expressions, see the <code class="directive"><a href="#redirectmatch">RedirectMatch</a></code> directive.</p>
344 <div class="note"><h3>Note</h3>
345 <p>Redirect directives take precedence over Alias and ScriptAlias
346 directives, irrespective of their ordering in the configuration
347 file. Redirect directives inside a Location take precedence over
348 Redirect and Alias directives with an URL-path.</p></div>
350 <p>If no <var>status</var> argument is given, the redirect will
351 be "temporary" (HTTP status 302). This indicates to the client
352 that the resource has moved temporarily. The <var>status</var>
353 argument can be used to return other HTTP status codes:</p>
358 <dd>Returns a permanent redirect status (301) indicating that
359 the resource has moved permanently.</dd>
363 <dd>Returns a temporary redirect status (302). This is the
368 <dd>Returns a "See Other" status (303) indicating that the
369 resource has been replaced.</dd>
373 <dd>Returns a "Gone" status (410) indicating that the
374 resource has been permanently removed. When this status is
375 used the <var>URL</var> argument should be omitted.</dd>
378 <p>Other status codes can be returned by giving the numeric
379 status code as the value of <var>status</var>. If the status is
380 between 300 and 399, the <var>URL</var> argument must be present.
381 If the status is <em>not</em> between 300 and 399, the
382 <var>URL</var> argument must be omitted. The status must be a valid
383 HTTP status code, known to the Apache HTTP Server (see the function
384 <code>send_error_response</code> in http_protocol.c).</p>
386 <pre class="prettyprint lang-config">Redirect permanent "/one" "http://example.com/two"
387 Redirect 303 "/three" "http://example.com/other"</pre>
390 <p>If the <code class="directive">Redirect</code> directive is used within a
391 <code class="directive"><a href="../mod/core.html#location"><Location></a></code>
392 or <code class="directive"><a href="../mod/core.html#locationmatch"><LocationMatch></a></code>
393 section with the URL-path omitted, then the URL parameter will be
394 interpreted using <a href="../expr.html">expression syntax</a>.<br />
395 This syntax is available in Apache 2.4.19 and later.</p>
397 <pre class="prettyprint lang-config"><Location "/one">
398 Redirect permanent "http://example.com/two"
400 <Location "/three">
401 Redirect 303 "http://example.com/other"
403 <LocationMatch "/error/(?<NUMBER>[0-9]+)">
404 Redirect permanent "http://example.com/errors/%{env:MATCH_NUMBER}.html"
405 </LocationMatch></pre>
410 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
411 <div class="directive-section"><h2><a name="RedirectMatch" id="RedirectMatch">RedirectMatch</a> <a name="redirectmatch" id="redirectmatch">Directive</a></h2>
412 <table class="directive">
413 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sends an external redirect based on a regular expression match
414 of the current URL</td></tr>
415 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RedirectMatch [<var>status</var>] <var>regex</var>
416 <var>URL</var></code></td></tr>
417 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
418 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
419 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
420 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
422 <p>This directive is equivalent to <code class="directive"><a href="#redirect">Redirect</a></code>, but makes use of
423 <a class="glossarylink" href="../glossary.html#regex" title="see glossary">regular expressions</a>,
424 instead of simple prefix matching. The
425 supplied regular expression is matched against the URL-path, and
426 if it matches, the server will substitute any parenthesized
427 matches into the given string and use it as a filename. For
428 example, to redirect all GIF files to like-named JPEG files on
429 another server, one might use:</p>
431 <pre class="prettyprint lang-config">RedirectMatch "(.*)\.gif$" "http://other.example.com$1.jpg"</pre>
434 <p>The considerations related to the difference between
435 <code class="directive"><a href="#alias">Alias</a></code> and
436 <code class="directive"><a href="#aliasmatch">AliasMatch</a></code>
437 also apply to the difference between
438 <code class="directive"><a href="#redirect">Redirect</a></code> and
439 <code class="directive"><a href="#redirectmatch">RedirectMatch</a></code>.
440 See <code class="directive"><a href="#aliasmatch">AliasMatch</a></code> for
445 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
446 <div class="directive-section"><h2><a name="RedirectPermanent" id="RedirectPermanent">RedirectPermanent</a> <a name="redirectpermanent" id="redirectpermanent">Directive</a></h2>
447 <table class="directive">
448 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sends an external permanent redirect asking the client to fetch
449 a different URL</td></tr>
450 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RedirectPermanent <var>URL-path</var> <var>URL</var></code></td></tr>
451 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
452 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
453 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
454 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
456 <p>This directive makes the client know that the Redirect is
457 permanent (status 301). Exactly equivalent to <code>Redirect
458 permanent</code>.</p>
461 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
462 <div class="directive-section"><h2><a name="RedirectTemp" id="RedirectTemp">RedirectTemp</a> <a name="redirecttemp" id="redirecttemp">Directive</a></h2>
463 <table class="directive">
464 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sends an external temporary redirect asking the client to fetch
465 a different URL</td></tr>
466 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RedirectTemp <var>URL-path</var> <var>URL</var></code></td></tr>
467 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
468 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
469 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
470 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
472 <p>This directive makes the client know that the Redirect is
473 only temporary (status 302). Exactly equivalent to
474 <code>Redirect temp</code>.</p>
477 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
478 <div class="directive-section"><h2><a name="ScriptAlias" id="ScriptAlias">ScriptAlias</a> <a name="scriptalias" id="scriptalias">Directive</a></h2>
479 <table class="directive">
480 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps a URL to a filesystem location and designates the
481 target as a CGI script</td></tr>
482 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ScriptAlias [<var>URL-path</var>]
483 <var>file-path</var>|<var>directory-path</var></code></td></tr>
484 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory</td></tr>
485 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
486 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
488 <p>The <code class="directive">ScriptAlias</code> directive has the same
489 behavior as the <code class="directive"><a href="#alias">Alias</a></code>
490 directive, except that in addition it marks the target directory
491 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 case-sensitive
492 (%-decoded) path beginning with <var>URL-path</var> will be mapped
493 to scripts beginning with the second argument, which is a full
494 pathname in the local filesystem.</p>
496 <pre class="prettyprint lang-config">ScriptAlias "/cgi-bin/" "/web/cgi-bin/"</pre>
499 <p>A request for <code>http://example.com/cgi-bin/foo</code> would cause the
500 server to run the script <code>/web/cgi-bin/foo</code>. This configuration
501 is essentially equivalent to:</p>
502 <pre class="prettyprint lang-config">Alias "/cgi-bin/" "/web/cgi-bin/"
503 <Location "/cgi-bin">
504 SetHandler cgi-script
506 </Location></pre>
509 <p><code class="directive">ScriptAlias</code> can also be used in conjunction with
510 a script or handler you have. For example:</p>
512 <pre class="prettyprint lang-config">ScriptAlias "/cgi-bin/" "/web/cgi-handler.pl"</pre>
515 <p>In this scenario all files requested in <code>/cgi-bin/</code> will be
516 handled by the file you have configured, this allows you to use your own custom
517 handler. You may want to use this as a wrapper for CGI so that you can add
518 content, or some other bespoke action.</p>
520 <div class="warning">It is safer to avoid placing CGI scripts under the
521 <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code> in order to
522 avoid accidentally revealing their source code if the
523 configuration is ever changed. The
524 <code class="directive">ScriptAlias</code> makes this easy by mapping a
525 URL and designating CGI scripts at the same time. If you do
526 choose to place your CGI scripts in a directory already
527 accessible from the web, do not use
528 <code class="directive">ScriptAlias</code>. Instead, use <code class="directive"><a href="../mod/core.html#directory"><Directory></a></code>, <code class="directive"><a href="../mod/core.html#sethandler">SetHandler</a></code>, and <code class="directive"><a href="../mod/core.html#options">Options</a></code> as in:
529 <pre class="prettyprint lang-config"><Directory "/usr/local/apache2/htdocs/cgi-bin">
530 SetHandler cgi-script
532 </Directory></pre>
534 This is necessary since multiple <var>URL-paths</var> can map
535 to the same filesystem location, potentially bypassing the
536 <code class="directive">ScriptAlias</code> and revealing the source code
537 of the CGI scripts if they are not restricted by a
538 <code class="directive"><a href="../mod/core.html#directory">Directory</a></code> section.</div>
540 <p>If the <code class="directive">ScriptAlias</code> directive is used within
541 a <code class="directive"><a href="../mod/core.html#location"><Location></a></code>
542 or <code class="directive"><a href="../mod/core.html#locationmatch"><LocationMatch></a></code>
543 section with the URL-path omitted, then the URL parameter will be
544 interpreted using <a href="../expr.html">expression syntax</a>.<br />
545 This syntax is available in Apache 2.4.19 and later.</p>
547 <pre class="prettyprint lang-config"><Location "/cgi-bin">
548 ScriptAlias "/web/cgi-bin/"
550 <LocationMatch "/cgi-bin/errors/(?<NUMBER>[0-9]+)">
551 ScriptAlias "/web/cgi-bin/errors/%{env:MATCH_NUMBER}.cgi"
552 </LocationMatch></pre>
558 <li><a href="../howto/cgi.html">CGI Tutorial</a></li>
561 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
562 <div class="directive-section"><h2><a name="ScriptAliasMatch" id="ScriptAliasMatch">ScriptAliasMatch</a> <a name="scriptaliasmatch" id="scriptaliasmatch">Directive</a></h2>
563 <table class="directive">
564 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps a URL to a filesystem location using a regular expression
565 and designates the target as a CGI script</td></tr>
566 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ScriptAliasMatch <var>regex</var>
567 <var>file-path</var>|<var>directory-path</var></code></td></tr>
568 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
569 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
570 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
572 <p>This directive is equivalent to <code class="directive"><a href="#scriptalias">ScriptAlias</a></code>, but makes use of
573 <a class="glossarylink" href="../glossary.html#regex" title="see glossary">regular expressions</a>,
574 instead of simple prefix matching. The
575 supplied regular expression is matched against the URL-path,
576 and if it matches, the server will substitute any parenthesized
577 matches into the given string and use it as a filename. For
578 example, to activate the standard <code>/cgi-bin</code>, one
581 <pre class="prettyprint lang-config">ScriptAliasMatch "^/cgi-bin(.*)" "/usr/local/apache/cgi-bin$1"</pre>
584 <p>As for AliasMatch, the full range of <a class="glossarylink" href="../glossary.html#rexex" title="see glossary">regular
585 expression</a> power is available.
586 For example, it is possible to construct an alias with case-insensitive
587 matching of the URL-path:</p>
589 <pre class="prettyprint lang-config">ScriptAliasMatch "(?i)^/cgi-bin(.*)" "/usr/local/apache/cgi-bin$1"</pre>
592 <p>The considerations related to the difference between
593 <code class="directive"><a href="#alias">Alias</a></code> and
594 <code class="directive"><a href="#aliasmatch">AliasMatch</a></code>
595 also apply to the difference between
596 <code class="directive"><a href="#scriptalias">ScriptAlias</a></code> and
597 <code class="directive"><a href="#scriptaliasmatch">ScriptAliasMatch</a></code>.
598 See <code class="directive"><a href="#aliasmatch">AliasMatch</a></code> for
604 <div class="bottomlang">
605 <p><span>Available Languages: </span><a href="../en/mod/mod_alias.html" title="English"> en </a> |
606 <a href="../fr/mod/mod_alias.html" hreflang="fr" rel="alternate" title="Français"> fr </a> |
607 <a href="../ja/mod/mod_alias.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
608 <a href="../ko/mod/mod_alias.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> |
609 <a href="../tr/mod/mod_alias.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p>
610 </div><div class="top"><a href="#page-header"><img src="../images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
611 <script type="text/javascript"><!--//--><![CDATA[//><!--
612 var comments_shortname = 'httpd';
613 var comments_identifier = 'http://httpd.apache.org/docs/trunk/mod/mod_alias.html';
615 if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
616 d.write('<div id="comments_thread"><\/div>');
617 var s = d.createElement('script');
618 s.type = 'text/javascript';
620 s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
621 (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
624 d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
626 })(window, document);
627 //--><!]]></script></div><div id="footer">
628 <p class="apache">Copyright 2016 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>
629 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/quickreference.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
630 if (typeof(prettyPrint) !== 'undefined') {