]> granicus.if.org Git - apache/blobdiff - docs/manual/mod/mod_alias.html.en
* Remove trailing whitespace from a bunch of *.xml files
[apache] / docs / manual / mod / mod_alias.html.en
index eff1f68eace91d4c51bb6647227b90c38d886d37..295c1f2d6d405a8fe80abe45091374c13319884b 100644 (file)
@@ -5,7 +5,7 @@
               This file is generated from xml source: DO NOT EDIT
         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
       -->
-<title>mod_alias - Apache HTTP Server</title>
+<title>mod_alias - Apache HTTP Server Version 2.5</title>
 <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
 <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
 <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" />
     a different URL. They are often used when a resource has moved to
     a new location.</p>
 
+    <p>When the <code class="directive"><a href="#alias">Alias</a></code>,
+    <code class="directive"><a href="#scriptalias">ScriptAlias</a></code> and
+    <code class="directive"><a href="#redirect">Redirect</a></code> directives are used
+    within a <code class="directive"><a href="../mod/core.html#location">&lt;Location&gt;</a></code>
+    or <code class="directive"><a href="../mod/core.html#locationmatch">&lt;LocationMatch&gt;</a></code>
+    section, <a href="../expr.html">expression syntax</a> can be used
+    to manipulate the destination path or URL.
+       </p>
+
     <p><code class="module"><a href="../mod/mod_alias.html">mod_alias</a></code> is designed to handle simple URL
     manipulation tasks.  For more complicated tasks such as
     manipulating the query string, use the tools provided by
     <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>.</p>
 
 </div>
-<div id="quickview"><h3 class="directives">Directives</h3>
+<div id="quickview"><h3>Topics</h3>
+<ul id="topics">
+<li><img alt="" src="../images/down.gif" /> <a href="#order">Order of Processing</a></li>
+</ul><h3 class="directives">Directives</h3>
 <ul id="toc">
 <li><img alt="" src="../images/down.gif" /> <a href="#alias">Alias</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#aliasmatch">AliasMatch</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#scriptalias">ScriptAlias</a></li>
 <li><img alt="" src="../images/down.gif" /> <a href="#scriptaliasmatch">ScriptAliasMatch</a></li>
 </ul>
-<h3>Topics</h3>
-<ul id="topics">
-<li><img alt="" src="../images/down.gif" /> <a href="#order">Order of Processing</a></li>
-</ul><h3>See also</h3>
+<h3>See also</h3>
 <ul class="seealso">
 <li><code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code></li>
 <li><a href="../urlmapping.html">Mapping URLs to the filesystem</a></li>
     all the directives to have an effect.  For example, the following
     configuration will work as expected:</p>
 
-    <pre class="prettyprint lang-config">Alias /foo/bar /baz
-Alias /foo /gaq</pre>
+    <pre class="prettyprint lang-config">Alias "/foo/bar" "/baz"
+Alias "/foo"     "/gaq"</pre>
 
 
     <p>But if the above two directives were reversed in order, the
@@ -106,14 +115,24 @@ Alias /foo /gaq</pre>
     would always match before the <code>/foo/bar</code> <code class="directive"><a href="#alias">Alias</a></code>, so the latter directive would be
     ignored.</p>
 
+    <p>When the <code class="directive"><a href="#alias">Alias</a></code>,
+    <code class="directive"><a href="#scriptalias">ScriptAlias</a></code> and
+    <code class="directive"><a href="#redirect">Redirect</a></code> directives are used
+    within a <code class="directive"><a href="../mod/core.html#location">&lt;Location&gt;</a></code>
+    or <code class="directive"><a href="../mod/core.html#locationmatch">&lt;LocationMatch&gt;</a></code>
+    section, these directives will take precedence over any globally
+    defined <code class="directive"><a href="#alias">Alias</a></code>,
+    <code class="directive"><a href="#scriptalias">ScriptAlias</a></code> and
+    <code class="directive"><a href="#redirect">Redirect</a></code> directives.</p>
+
 </div>
 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="directive-section"><h2><a name="Alias" id="Alias">Alias</a> <a name="alias" id="alias">Directive</a></h2>
 <table class="directive">
 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps URLs to filesystem locations</td></tr>
-<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>Alias <var>URL-path</var>
+<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>Alias [<var>URL-path</var>]
 <var>file-path</var>|<var>directory-path</var></code></td></tr>
-<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
+<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory</td></tr>
 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
 </table>
@@ -126,7 +145,7 @@ Alias /foo /gaq</pre>
     <var>URL-path</var> is case-sensitive, even on case-insensitive
     file systems.</p>
 
-    <pre class="prettyprint lang-config">      Alias /image /ftp/pub/image</pre>
+    <pre class="prettyprint lang-config">Alias "/image" "/ftp/pub/image"</pre>
 
 
     <p>A request for <code>http://example.com/image/foo.gif</code> would cause
@@ -139,7 +158,7 @@ Alias /foo /gaq</pre>
     <var>URL-path</var> then the server will require a trailing / in
     order to expand the alias. That is, if you use</p>
 
-    <pre class="prettyprint lang-config">      Alias /icons/ /usr/local/apache/icons/</pre>
+    <pre class="prettyprint lang-config">Alias "/icons/" "/usr/local/apache/icons/"</pre>
 
 
     <p>then the url <code>/icons</code> will not be aliased, as it lacks
@@ -159,15 +178,29 @@ Alias /foo /gaq</pre>
     directory outside of your <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code>, you may need to explicitly
     permit access to the target directory.</p>
 
-    <pre class="prettyprint lang-config">Alias /image /ftp/pub/image
-&lt;Directory /ftp/pub/image&gt;
+    <pre class="prettyprint lang-config">Alias "/image" "/ftp/pub/image"
+&lt;Directory "/ftp/pub/image"&gt;
     Require all granted
 &lt;/Directory&gt;</pre>
 
 
-    <p>Any number slashes in the <var>URL-path</var> parameter 
+    <p>Any number slashes in the <var>URL-path</var> parameter
     matches any number of slashes in the requested URL-path.</p>
 
+    <p>If the <code class="directive">Alias</code> directive is used within a
+    <code class="directive"><a href="../mod/core.html#location">&lt;Location&gt;</a></code>
+    or <code class="directive"><a href="../mod/core.html#locationmatch">&lt;LocationMatch&gt;</a></code>
+    section the URL-path is omitted, and the file-path is interpreted
+    using <a href="../expr.html">expression syntax</a>.</p>
+
+    <pre class="prettyprint lang-config">&lt;Location "/image"&gt;
+    Alias "/ftp/pub/image"
+&lt;/Location&gt;
+&lt;LocationMatch "/error/(?&lt;NUMBER&gt;[0-9]+)"&gt;
+    Alias "/usr/local/apache/errors/%{env:MATCH_NUMBER}.html"
+&lt;/LocationMatch&gt;</pre>
+
+
 
 </div>
 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
@@ -190,7 +223,7 @@ expressions</td></tr>
     example, to activate the <code>/icons</code> directory, one might
     use:</p>
 
-    <pre class="prettyprint lang-config">      AliasMatch ^/icons(.*) /usr/local/apache/icons$1</pre>
+    <pre class="prettyprint lang-config">AliasMatch "^/icons(/|$)(.*)" "/usr/local/apache/icons$1$2"</pre>
 
 
     <p>The full range of <a class="glossarylink" href="../glossary.html#regex" title="see glossary">regular expression</a>
@@ -198,7 +231,7 @@ expressions</td></tr>
     it is possible to construct an alias with case-insensitive
     matching of the URL-path:</p>
 
-    <pre class="prettyprint lang-config">      AliasMatch (?i)^/image(.*) /ftp/pub/image$1</pre>
+    <pre class="prettyprint lang-config">AliasMatch "(?i)^/image(.*)" "/ftp/pub/image$1"</pre>
 
 
     <p>One subtle difference
@@ -222,18 +255,18 @@ expressions</td></tr>
 
     <p>For example, suppose you want to replace this with AliasMatch:</p>
 
-    <pre class="prettyprint lang-config">      Alias /image/ /ftp/pub/image/</pre>
+    <pre class="prettyprint lang-config">Alias "/image/" "/ftp/pub/image/"</pre>
 
 
     <p>This is NOT equivalent - don't do this!  This will send all
     requests that have /image/ anywhere in them to /ftp/pub/image/:</p>
 
-    <pre class="prettyprint lang-config">      AliasMatch /image/ /ftp/pub/image/</pre>
+    <pre class="prettyprint lang-config">AliasMatch "/image/" "/ftp/pub/image/"</pre>
 
 
     <p>This is what you need to get the same effect:</p>
 
-    <pre class="prettyprint lang-config">      AliasMatch ^/image/(.*)$ /ftp/pub/image/$1</pre>
+    <pre class="prettyprint lang-config">AliasMatch "^/image/(.*)$" "/ftp/pub/image/$1"</pre>
 
 
     <p>Of course, there's no point in
@@ -243,8 +276,8 @@ expressions</td></tr>
     you do more complicated things.  For example, you could
     serve different kinds of files from different directories:</p>
 
-    <pre class="prettyprint lang-config">      AliasMatch ^/image/(.*)\.jpg$ /files/jpg.images/$1.jpg<br />
-      AliasMatch ^/image/(.*)\.gif$ /files/gif.images/$1.gif</pre>
+    <pre class="prettyprint lang-config">AliasMatch "^/image/(.*)\.jpg$" "/files/jpg.images/$1.jpg"<br />
+AliasMatch "^/image/(.*)\.gif$" "/files/gif.images/$1.gif"</pre>
 
 
     <p>Multiple leading slashes in the requested URL are discarded
@@ -259,7 +292,7 @@ expressions</td></tr>
 <table class="directive">
 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sends an external redirect asking the client to fetch
 a different URL</td></tr>
-<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>Redirect [<var>status</var>] <var>URL-path</var>
+<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>Redirect [<var>status</var>] [<var>URL-path</var>]
 <var>URL</var></code></td></tr>
 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
@@ -283,10 +316,10 @@ a different URL</td></tr>
     <em>URL-Path</em> will be appended to the target URL.</p>
 
     <pre class="prettyprint lang-config"># Redirect to a URL on a different host
-Redirect /service http://foo2.example.com/service
+Redirect "/service" "http://foo2.example.com/service"
 
 # Redirect to a URL on the same host
-Redirect /one /two</pre>
+Redirect "/one" "/two"</pre>
 
 
     <p>If the client requests <code>http://example.com/service/foo.txt</code>,
@@ -299,14 +332,17 @@ Redirect /one /two</pre>
        Note that <code>POST</code>s will be discarded.<br />
        Only complete path segments are matched, so the above
     example would not match a request for
-    <code>http://example.com/servicefoo.txt</code>.  For more complex matching
-    using regular expressions, see the <code class="directive"><a href="#redirectmatch">RedirectMatch</a></code> directive.</p>
+    <code>http://example.com/servicefoo.txt</code>. For more complex matching
+    using the <a href="../expr.html">expression syntax</a>, omit the URL-path
+    argument as described below. Alternatively, for matching using regular
+    expressions, see the <code class="directive"><a href="#redirectmatch">RedirectMatch</a></code> directive.</p>
 
 
     <div class="note"><h3>Note</h3>
     <p>Redirect directives take precedence over Alias and ScriptAlias
     directives, irrespective of their ordering in the configuration
-    file.</p></div>
+    file. Redirect directives inside a Location take precedence over
+    Redirect and Alias directives with an URL-path.</p></div>
 
     <p>If no <var>status</var> argument is given, the redirect will
     be "temporary" (HTTP status 302). This indicates to the client
@@ -344,8 +380,26 @@ Redirect /one /two</pre>
     HTTP status code, known to the Apache HTTP Server (see the function
     <code>send_error_response</code> in http_protocol.c).</p>
 
-    <pre class="prettyprint lang-config">Redirect permanent /one http://example.com/two
-Redirect 303 /three http://example.com/other</pre>
+    <pre class="prettyprint lang-config">Redirect permanent "/one" "http://example.com/two"
+Redirect 303 "/three" "http://example.com/other"</pre>
+
+
+    <p>If the <code class="directive">Redirect</code> directive is used within a
+    <code class="directive"><a href="../mod/core.html#location">&lt;Location&gt;</a></code>
+    or <code class="directive"><a href="../mod/core.html#locationmatch">&lt;LocationMatch&gt;</a></code>
+    section with the URL-path omitted, then the URL parameter will be
+    interpreted using <a href="../expr.html">expression syntax</a>.</p>
+
+    <pre class="prettyprint lang-config">&lt;Location "/one"&gt;
+    Redirect permanent "http://example.com/two"
+&lt;/Location&gt;<br />
+&lt;Location "/three"&gt;
+    Redirect 303 "http://example.com/other"
+&lt;/Location&gt;<br />
+&lt;LocationMatch "/error/(?&lt;NUMBER&gt;[0-9]+)"&gt;
+    Redirect permanent "http://example.com/errors/%{env:MATCH_NUMBER}.html"
+&lt;/LocationMatch&gt;<br />
+    </pre>
 
 
 
@@ -371,7 +425,7 @@ of the current URL</td></tr>
     example, to redirect all GIF files to like-named JPEG files on
     another server, one might use:</p>
 
-    <pre class="prettyprint lang-config">      RedirectMatch (.*)\.gif$ http://other.example.com$1.jpg</pre>
+    <pre class="prettyprint lang-config">RedirectMatch "(.*)\.gif$" "http://other.example.com$1.jpg"</pre>
 
 
     <p>The considerations related to the difference between
@@ -423,9 +477,9 @@ a different URL</td></tr>
 <table class="directive">
 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps a URL to a filesystem location and designates the
 target as a CGI script</td></tr>
-<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ScriptAlias <var>URL-path</var>
+<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ScriptAlias [<var>URL-path</var>]
 <var>file-path</var>|<var>directory-path</var></code></td></tr>
-<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
+<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory</td></tr>
 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
 </table>
@@ -437,14 +491,14 @@ target as a CGI script</td></tr>
     to scripts beginning with the second argument, which is a full
     pathname in the local filesystem.</p>
 
-    <pre class="prettyprint lang-config">      ScriptAlias /cgi-bin/ /web/cgi-bin/</pre>
+    <pre class="prettyprint lang-config">ScriptAlias "/cgi-bin/" "/web/cgi-bin/"</pre>
 
 
     <p>A request for <code>http://example.com/cgi-bin/foo</code> would cause the
     server to run the script <code>/web/cgi-bin/foo</code>.  This configuration
     is essentially equivalent to:</p>
-    <pre class="prettyprint lang-config">Alias /cgi-bin/ /web/cgi-bin/
-&lt;Location /cgi-bin &gt;
+    <pre class="prettyprint lang-config">Alias "/cgi-bin/" "/web/cgi-bin/"
+&lt;Location "/cgi-bin"&gt;
     SetHandler cgi-script
     Options +ExecCGI
 &lt;/Location&gt;</pre>
@@ -453,7 +507,7 @@ target as a CGI script</td></tr>
        <p><code class="directive">ScriptAlias</code> can also be used in conjunction with
        a script or handler you have. For example:</p>
 
-       <pre class="prettyprint lang-config">     ScriptAlias /cgi-bin/ /web/cgi-handler.pl</pre>
+       <pre class="prettyprint lang-config">ScriptAlias "/cgi-bin/" "/web/cgi-handler.pl"</pre>
 
 
     <p>In this scenario all files requested in <code>/cgi-bin/</code> will be
@@ -470,7 +524,7 @@ target as a CGI script</td></tr>
     choose to place your CGI scripts in a directory already
     accessible from the web, do not use
     <code class="directive">ScriptAlias</code>.  Instead, use <code class="directive"><a href="../mod/core.html#directory">&lt;Directory&gt;</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:
-    <pre class="prettyprint lang-config">&lt;Directory /usr/local/apache2/htdocs/cgi-bin &gt;
+    <pre class="prettyprint lang-config">&lt;Directory "/usr/local/apache2/htdocs/cgi-bin"&gt;
     SetHandler cgi-script
     Options ExecCGI
 &lt;/Directory&gt;</pre>
@@ -481,6 +535,21 @@ target as a CGI script</td></tr>
     of the CGI scripts if they are not restricted by a
     <code class="directive"><a href="../mod/core.html#directory">Directory</a></code> section.</div>
 
+    <p>If the <code class="directive">ScriptAlias</code> directive is used within
+    a <code class="directive"><a href="../mod/core.html#location">&lt;Location&gt;</a></code>
+    or <code class="directive"><a href="../mod/core.html#locationmatch">&lt;LocationMatch&gt;</a></code>
+    section with the URL-path omitted, then the URL parameter will be
+    interpreted using <a href="../expr.html">expression syntax</a>.</p>
+
+    <pre class="prettyprint lang-config">&lt;Location "/cgi-bin"&gt;
+    ScriptAlias "/web/cgi-bin/"
+&lt;/Location&gt;
+&lt;LocationMatch "/cgi-bin/errors/(?&lt;NUMBER&gt;[0-9]+)"&gt;
+    ScriptAlias "/web/cgi-bin/errors/%{env:MATCH_NUMBER}.cgi"
+&lt;/LocationMatch&gt;<br />
+    </pre>
+
+
 
 <h3>See also</h3>
 <ul>
@@ -507,7 +576,7 @@ and designates the target as a CGI script</td></tr>
     example, to activate the standard <code>/cgi-bin</code>, one
     might use:</p>
 
-    <pre class="prettyprint lang-config">      ScriptAliasMatch ^/cgi-bin(.*) /usr/local/apache/cgi-bin$1</pre>
+    <pre class="prettyprint lang-config">ScriptAliasMatch "^/cgi-bin(.*)" "/usr/local/apache/cgi-bin$1"</pre>
 
 
     <p>As for AliasMatch, the full range of <a class="glossarylink" href="../glossary.html#rexex" title="see glossary">regular
@@ -515,7 +584,7 @@ and designates the target as a CGI script</td></tr>
     For example, it is possible to construct an alias with case-insensitive
     matching of the URL-path:</p>
 
-    <pre class="prettyprint lang-config">      ScriptAliasMatch (?i)^/cgi-bin(.*) /usr/local/apache/cgi-bin$1</pre>
+    <pre class="prettyprint lang-config">ScriptAliasMatch "(?i)^/cgi-bin(.*)" "/usr/local/apache/cgi-bin$1"</pre>
 
 
     <p>The considerations related to the difference between
@@ -554,7 +623,7 @@ var comments_identifier = 'http://httpd.apache.org/docs/trunk/mod/mod_alias.html
     }
 })(window, document);
 //--><!]]></script></div><div id="footer">
-<p class="apache">Copyright 2014 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>
+<p class="apache">Copyright 2015 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>
 <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[//><!--
 if (typeof(prettyPrint) !== 'undefined') {
     prettyPrint();