mod_alias.xml revision e32abf00422bf50d92c28c448f60b951c8fa42ea
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<?xml version="1.0"?>
530eba85dbd41b8a0fa5255d3648d1440199a661slive<!DOCTYPE modulesynopsis SYSTEM "/style/modulesynopsis.dtd">
e942c741056732f50da2074b36fe59805d370650slive<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
5f5d1b4cc970b7f06ff8ef6526128e9a27303d88nd<!-- $LastChangedRevision$ -->
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd<!--
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding Licensed to the Apache Software Foundation (ASF) under one or more
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding contributor license agreements. See the NOTICE file distributed with
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding this work for additional information regarding copyright ownership.
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding The ASF licenses this file to You under the Apache License, Version 2.0
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding (the "License"); you may not use this file except in compliance with
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding the License. You may obtain a copy of the License at
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd http://www.apache.org/licenses/LICENSE-2.0
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd Unless required by applicable law or agreed to in writing, software
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd distributed under the License is distributed on an "AS IS" BASIS,
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd See the License for the specific language governing permissions and
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd limitations under the License.
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd-->
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd
7db9f691a00ead175b03335457ca296a33ddf31bnd<modulesynopsis metafile="mod_alias.xml.meta">
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<name>mod_alias</name>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<description>Provides for mapping different parts of the host
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive filesystem in the document tree and for URL redirection</description>
530eba85dbd41b8a0fa5255d3648d1440199a661slive<status>Base</status>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<sourcefile>mod_alias.c</sourcefile>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna<identifier>alias_module</identifier>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna<summary>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <p>The directives contained in this module allow for manipulation
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna and control of URLs as requests arrive at the server. The
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <directive module="mod_alias">Alias</directive> and <directive
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna module="mod_alias">ScriptAlias</directive> directives are used to
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna map between URLs and filesystem paths. This allows for content
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna which is not directly under the <directive
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna module="core">DocumentRoot</directive> served as part of the web
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna document tree. The <directive
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna module="mod_alias">ScriptAlias</directive> directive has the
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna additional effect of marking the target directory as containing
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna only CGI scripts.</p>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <p>The <directive module="mod_alias">Redirect</directive>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna directives are used to instruct clients to make a new request with
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna a different URL. They are often used when a resource has moved to
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna a new location.</p>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <p><module>mod_alias</module> is designed to handle simple URL
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna manipulation tasks. For more complicated tasks such as
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna manipulating the query string, use the tools provided by
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <module>mod_rewrite</module>.</p>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna</summary>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna<seealso><module>mod_rewrite</module></seealso> <seealso><a
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquernahref="/urlmapping.html">Mapping URLs to the filesystem</a></seealso>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna<section id="order"><title>Order of Processing</title>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <p>Aliases and Redirects occuring in different contexts are processed
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna like other directives according to standard <a
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna href="/sections.html#mergin">merging rules</a>. But when multiple
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna Aliases or Redirects occur in the same context (for example, in the
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna same <directive type="section" module="core">VirtualHost</directive>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna section) they are processed in a particular order.</p>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <p>First, all Redirects are processed before Aliases are processed,
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna and therefore a request that matches a <directive
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna module="mod_alias">Redirect</directive> or <directive
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna module="mod_alias">RedirectMatch</directive> will never have Aliases
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna applied. Second, the Aliases and Redirects are processed in the order
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna they appear in the configuration files, with the first match taking
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna precedence.</p>
3139522a1418fa699dfd78dcf8dde54253f2c55cnoirin
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <p>For this reason, when two or more of these directives apply to the
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna same sub-path, you must list the most specific path first in order for
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna all the directives to have an effect. For example, the following
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna configuration will work as expected:</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <example>
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess Alias /foo/bar /baz<br />
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive Alias /foo /gaq
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive </example>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>But if the above two directives were reversed in order, the
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <code>/foo</code> <directive module="mod_alias">Alias</directive>
18b4b0fd6056093002ddef488636bf5ebe415ef0erikabele would always match before the <code>/foo/bar</code> <directive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive module="mod_alias">Alias</directive>, so the latter directive would be
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ignored.</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</section>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<name>Alias</name>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<description>Maps URLs to filesystem locations</description>
fb77c505254b6e9c925e23e734463e87574f8f40kess<syntax>Alias <var>URL-path</var>
fb77c505254b6e9c925e23e734463e87574f8f40kess<var>file-path</var>|<var>directory-path</var></syntax>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<contextlist><context>server config</context><context>virtual host</context>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</contextlist>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<usage>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>The <directive>Alias</directive> directive allows documents to
fb77c505254b6e9c925e23e734463e87574f8f40kess be stored in the local filesystem other than under the
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <directive module="core">DocumentRoot</directive>. URLs with a
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive (%-decoded) path beginning with <var>url-path</var> will be mapped
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive to local files beginning with <var>directory-path</var>. The
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <var>url-path</var> is case-sensitive, even on case-insensitive
fb77c505254b6e9c925e23e734463e87574f8f40kess file systems.</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <example><title>Example:</title>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive Alias /image /ftp/pub/image
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive </example>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
fb77c505254b6e9c925e23e734463e87574f8f40kess <p>A request for <code>http://myserver/image/foo.gif</code> would cause
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive the server to return the file <code>/ftp/pub/image/foo.gif</code>. Only
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive complete path segments are matched, so the above alias would not match a
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive request for <code>http://myserver/imagefoo.gif</code>. For more complex
fb77c505254b6e9c925e23e734463e87574f8f40kess matching using regular expressions, see the <directive module="mod_alias"
fb77c505254b6e9c925e23e734463e87574f8f40kess >AliasMatch</directive> directive.</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>Note that if you include a trailing / on the
fb77c505254b6e9c925e23e734463e87574f8f40kess <var>url-path</var> then the server will require a trailing / in
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess order to expand the alias. That is, if you use</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
bc4b55ec8f31569d606d5680d50189a355bcd7a6rbowen <dl><dd><code>Alias /icons/ /usr/local/apache/icons/</code></dd></dl>
fb77c505254b6e9c925e23e734463e87574f8f40kess
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>then the url <code>/icons</code> will not be aliased.</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>Note that you may need to specify additional <directive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive type="section" module="core">Directory</directive> sections which
fb77c505254b6e9c925e23e734463e87574f8f40kess cover the <em>destination</em> of aliases. Aliasing occurs before
fb77c505254b6e9c925e23e734463e87574f8f40kess <directive type="section" module="core">Directory</directive> sections
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive are checked, so only the destination of aliases are affected.
fb77c505254b6e9c925e23e734463e87574f8f40kess (Note however <directive type="section" module="core">Location</directive>
fb77c505254b6e9c925e23e734463e87574f8f40kess sections are run through once before aliases are performed, so
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive they will apply.)</p>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
130d299c4b2b15be45532a176604c71fdc7bea5bnd <p>In particular, if you are creating an <code>Alias</code> to a
130d299c4b2b15be45532a176604c71fdc7bea5bnd directory outside of your <directive
130d299c4b2b15be45532a176604c71fdc7bea5bnd module="core">DocumentRoot</directive>, you may need to explicitly
130d299c4b2b15be45532a176604c71fdc7bea5bnd permit access to the target directory.</p>
130d299c4b2b15be45532a176604c71fdc7bea5bnd
ef8e89e090461194ecadd31e8796a2c51e0531a2kess <example><title>Example:</title>
130d299c4b2b15be45532a176604c71fdc7bea5bnd Alias /image /ftp/pub/image<br />
130d299c4b2b15be45532a176604c71fdc7bea5bnd &lt;Directory /ftp/pub/image&gt;<br />
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd <indent>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd Order allow,deny<br />
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive Allow from all<br />
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive </indent>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive &lt;/Directory&gt;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive </example>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
003f0c9fda6664daf5092a0e42f65ede20098153slive</usage>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd</directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<name>AliasMatch</name>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<description>Maps URLs to filesystem locations using regular
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveexpressions</description>
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess<syntax>AliasMatch <var>regex</var>
003f0c9fda6664daf5092a0e42f65ede20098153slive<var>file-path</var>|<var>directory-path</var></syntax>
003f0c9fda6664daf5092a0e42f65ede20098153slive<contextlist><context>server config</context><context>virtual host</context>
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess</contextlist>
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<usage>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd <p>This directive is equivalent to <directive
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd module="mod_alias">Alias</directive>, but makes use of
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd <glossary ref="regex">regular expressions</glossary>,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive instead of simple prefix matching. The
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive supplied regular expression is matched against the URL-path, and
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if it matches, the server will substitute any parenthesized
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive matches into the given string and use it as a filename. For
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive example, to activate the <code>/icons</code> directory, one might
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive use:</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
130d299c4b2b15be45532a176604c71fdc7bea5bnd <example>
130d299c4b2b15be45532a176604c71fdc7bea5bnd AliasMatch ^/icons(.*) /usr/local/apache/icons$1
130d299c4b2b15be45532a176604c71fdc7bea5bnd </example>
130d299c4b2b15be45532a176604c71fdc7bea5bnd
130d299c4b2b15be45532a176604c71fdc7bea5bnd <p>It is also possible to construct an alias with case-insensitive
130d299c4b2b15be45532a176604c71fdc7bea5bnd matching of the url-path:</p>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <example>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive AliasMatch (?i)^/image(.*) /ftp/pub/image$1
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive </example>
1a3f62ca37273a15a06bb94a61d3c6fcf4bf38c9rbowen
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</usage>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<directivesynopsis>
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding<name>Redirect</name>
684f2a9a422185adda0692a1203c5ad6687fc5c5nd<description>Sends an external redirect asking the client to fetch
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnda different URL</description>
530eba85dbd41b8a0fa5255d3648d1440199a661slive<syntax>Redirect [<var>status</var>] <var>URL-path</var>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<var>URL</var></syntax>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<contextlist><context>server config</context><context>virtual host</context>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<context>directory</context><context>.htaccess</context></contextlist>
003f0c9fda6664daf5092a0e42f65ede20098153slive<override>FileInfo</override>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<usage>
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding <p>The Redirect directive maps an old URL into a new one by asking
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding the client to refetch the resource at the new location.</p>
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding
684f2a9a422185adda0692a1203c5ad6687fc5c5nd <p>The old <em>URL-path</em> is a case-sensitive (%-decoded) path
a8ce9095d102e43fecb81093a132b90b9a227f78kess beginning with a slash. A relative path is not allowed.</p>
684f2a9a422185adda0692a1203c5ad6687fc5c5nd
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding <p>The new <em>URL</em> may be either an absolute URL beginning
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding with a scheme and hostname, or a URL-path beginning with a slash.
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding In this latter case the scheme and hostname of the current server will
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding be added.</p>
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding <p>Then any request beginning with <em>URL-Path</em> will return a
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding redirect request to the client at the location of the target
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <em>URL</em>. Additional path information beyond the matched
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd <em>URL-Path</em> will be appended to the target URL.</p>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd <example><title>Example:</title>
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding Redirect /service http://foo2.example.com/service<br />
684f2a9a422185adda0692a1203c5ad6687fc5c5nd <br />
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding # Redirect to a URL on the same host<br />
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding Redirect /one /two
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding </example>
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding <p>If the client requests <code>http://example.com/service/foo.txt</code>,
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding it will be told to access
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding <code>http://foo2.example.com/service/foo.txt</code>
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding instead. Only complete path segments are matched, so the above
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding example would not match a request for
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <code>http://example.com/servicefoo.txt</code>. For more complex matching
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding using regular expressions, see the <directive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive module="mod_alias">RedirectMatch</directive> directive.</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
58699879a562774640b95e9eedfd891f336e38c2nd
58699879a562774640b95e9eedfd891f336e38c2nd <note><title>Note</title>
58699879a562774640b95e9eedfd891f336e38c2nd <p>Redirect directives take precedence over Alias and ScriptAlias
fb77c505254b6e9c925e23e734463e87574f8f40kess directives, irrespective of their ordering in the configuration
fb77c505254b6e9c925e23e734463e87574f8f40kess file.</p></note>
58699879a562774640b95e9eedfd891f336e38c2nd
58699879a562774640b95e9eedfd891f336e38c2nd <p>If no <var>status</var> argument is given, the redirect will
58699879a562774640b95e9eedfd891f336e38c2nd be "temporary" (HTTP status 302). This indicates to the client
58699879a562774640b95e9eedfd891f336e38c2nd that the resource has moved temporarily. The <var>status</var>
a2920e90d95fa04c15bdbbc03e7f8636eac92423slive argument can be used to return other HTTP status codes:</p>
58699879a562774640b95e9eedfd891f336e38c2nd
58699879a562774640b95e9eedfd891f336e38c2nd <dl>
58699879a562774640b95e9eedfd891f336e38c2nd <dt>permanent</dt>
58699879a562774640b95e9eedfd891f336e38c2nd
a2920e90d95fa04c15bdbbc03e7f8636eac92423slive <dd>Returns a permanent redirect status (301) indicating that
a2920e90d95fa04c15bdbbc03e7f8636eac92423slive the resource has moved permanently.</dd>
a2920e90d95fa04c15bdbbc03e7f8636eac92423slive
58699879a562774640b95e9eedfd891f336e38c2nd <dt>temp</dt>
fb77c505254b6e9c925e23e734463e87574f8f40kess
fb77c505254b6e9c925e23e734463e87574f8f40kess <dd>Returns a temporary redirect status (302). This is the
fb77c505254b6e9c925e23e734463e87574f8f40kess default.</dd>
fb77c505254b6e9c925e23e734463e87574f8f40kess
fb77c505254b6e9c925e23e734463e87574f8f40kess <dt>seeother</dt>
58699879a562774640b95e9eedfd891f336e38c2nd
58699879a562774640b95e9eedfd891f336e38c2nd <dd>Returns a "See Other" status (303) indicating that the
58699879a562774640b95e9eedfd891f336e38c2nd resource has been replaced.</dd>
58699879a562774640b95e9eedfd891f336e38c2nd
58699879a562774640b95e9eedfd891f336e38c2nd <dt>gone</dt>
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess <dd>Returns a "Gone" status (410) indicating that the
58699879a562774640b95e9eedfd891f336e38c2nd resource has been permanently removed. When this status is
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess used the <var>URL</var> argument should be omitted.</dd>
58699879a562774640b95e9eedfd891f336e38c2nd </dl>
58699879a562774640b95e9eedfd891f336e38c2nd
fb77c505254b6e9c925e23e734463e87574f8f40kess <p>Other status codes can be returned by giving the numeric
fb77c505254b6e9c925e23e734463e87574f8f40kess status code as the value of <var>status</var>. If the status is
fb77c505254b6e9c925e23e734463e87574f8f40kess between 300 and 399, the <var>URL</var> argument must be present,
58699879a562774640b95e9eedfd891f336e38c2nd otherwise it must be omitted. Note that the status must be
58699879a562774640b95e9eedfd891f336e38c2nd known to the Apache code (see the function
58699879a562774640b95e9eedfd891f336e38c2nd <code>send_error_response</code> in http_protocol.c).</p>
58699879a562774640b95e9eedfd891f336e38c2nd
58699879a562774640b95e9eedfd891f336e38c2nd <example><title>Example:</title>
58699879a562774640b95e9eedfd891f336e38c2nd Redirect permanent /one http://example.com/two<br />
58699879a562774640b95e9eedfd891f336e38c2nd Redirect 303 /three http://example.com/other
58699879a562774640b95e9eedfd891f336e38c2nd </example>
58699879a562774640b95e9eedfd891f336e38c2nd
58699879a562774640b95e9eedfd891f336e38c2nd</usage>
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess</directivesynopsis>
4a7affccb2f1f5b94cab395e1bf3825aed715ebcnd
9b5e2c5e769dc678a1aca06df75c32022b2f1492trawick<directivesynopsis>
c14037646789087319802aaada2e8534ccab0158slive<name>RedirectMatch</name>
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess<description>Sends an external redirect based on a regular expression match
6b64034fa2a644ba291c484c0c01c7df5b8d982ckessof the current URL</description>
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess<syntax>RedirectMatch [<var>status</var>] <var>regex</var>
4a7affccb2f1f5b94cab395e1bf3825aed715ebcnd<var>URL</var></syntax>
4a7affccb2f1f5b94cab395e1bf3825aed715ebcnd<contextlist><context>server config</context><context>virtual host</context>
9b5e2c5e769dc678a1aca06df75c32022b2f1492trawick<context>directory</context><context>.htaccess</context></contextlist>
4a7affccb2f1f5b94cab395e1bf3825aed715ebcnd<override>FileInfo</override>
4a7affccb2f1f5b94cab395e1bf3825aed715ebcnd
4a7affccb2f1f5b94cab395e1bf3825aed715ebcnd<usage>
4a7affccb2f1f5b94cab395e1bf3825aed715ebcnd <p>This directive is equivalent to <directive
ec9b02c6869b75575ada34c800672162833a2c06nd module="mod_alias">Redirect</directive>, but makes use of
58699879a562774640b95e9eedfd891f336e38c2nd <glossary ref="regex">regular expressions</glossary>,
58699879a562774640b95e9eedfd891f336e38c2nd instead of simple prefix matching. The
58699879a562774640b95e9eedfd891f336e38c2nd supplied regular expression is matched against the URL-path, and
58699879a562774640b95e9eedfd891f336e38c2nd if it matches, the server will substitute any parenthesized
58699879a562774640b95e9eedfd891f336e38c2nd matches into the given string and use it as a filename. For
4a7affccb2f1f5b94cab395e1bf3825aed715ebcnd example, to redirect all GIF files to like-named JPEG files on
58699879a562774640b95e9eedfd891f336e38c2nd another server, one might use:</p>
58699879a562774640b95e9eedfd891f336e38c2nd
77ead9e0262e4f08ec336d1a65b2edef7705c839nd <example>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd RedirectMatch (.*)\.gif$ http://www.anotherserver.com$1.jpg
9583adab6bc4b3758e41963c905d9dad9f067131nd </example>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd</usage>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd</directivesynopsis>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd
77ead9e0262e4f08ec336d1a65b2edef7705c839nd<directivesynopsis>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd<name>RedirectTemp</name>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd<description>Sends an external temporary redirect asking the client to fetch
77ead9e0262e4f08ec336d1a65b2edef7705c839nda different URL</description>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd<syntax>RedirectTemp <var>URL-path</var> <var>URL</var></syntax>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd<contextlist><context>server config</context><context>virtual host</context>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd<context>directory</context><context>.htaccess</context></contextlist>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd<override>FileInfo</override>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd
77ead9e0262e4f08ec336d1a65b2edef7705c839nd<usage>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd <p>This directive makes the client know that the Redirect is
77ead9e0262e4f08ec336d1a65b2edef7705c839nd only temporary (status 302). Exactly equivalent to
77ead9e0262e4f08ec336d1a65b2edef7705c839nd <code>Redirect temp</code>.</p>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd</usage>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd</directivesynopsis>
9b5e2c5e769dc678a1aca06df75c32022b2f1492trawick
77ead9e0262e4f08ec336d1a65b2edef7705c839nd<directivesynopsis>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd<name>RedirectPermanent</name>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd<description>Sends an external permanent redirect asking the client to fetch
77ead9e0262e4f08ec336d1a65b2edef7705c839nda different URL</description>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd<syntax>RedirectPermanent <var>URL-path</var> <var>URL</var></syntax>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd<contextlist><context>server config</context><context>virtual host</context>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd<context>directory</context><context>.htaccess</context></contextlist>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<override>FileInfo</override>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
003f0c9fda6664daf5092a0e42f65ede20098153slive<usage>
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess <p>This directive makes the client know that the Redirect is
fb77c505254b6e9c925e23e734463e87574f8f40kess permanent (status 301). Exactly equivalent to <code>Redirect
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd permanent</code>.</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</usage>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<directivesynopsis>
fb77c505254b6e9c925e23e734463e87574f8f40kess<name>ScriptAlias</name>
fb77c505254b6e9c925e23e734463e87574f8f40kess<description>Maps a URL to a filesystem location and designates the
fb77c505254b6e9c925e23e734463e87574f8f40kesstarget as a CGI script</description>
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess<syntax>ScriptAlias <var>URL-path</var>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<var>file-path</var>|<var>directory-path</var></syntax>
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess<contextlist><context>server config</context><context>virtual host</context>
10673857794a4b3d9568ca2d983722a87ed352f1rbowen</contextlist>
fb77c505254b6e9c925e23e734463e87574f8f40kess
b12b918ae6baf9c5762ed61b7393d0e2198378c0nd<usage>
b12b918ae6baf9c5762ed61b7393d0e2198378c0nd <p>The <directive>ScriptAlias</directive> directive has the same
b12b918ae6baf9c5762ed61b7393d0e2198378c0nd behavior as the <directive module="mod_alias">Alias</directive>
b12b918ae6baf9c5762ed61b7393d0e2198378c0nd directive, except that in addition it marks the target directory
10673857794a4b3d9568ca2d983722a87ed352f1rbowen as containing CGI scripts that will be processed by <module
10673857794a4b3d9568ca2d983722a87ed352f1rbowen >mod_cgi</module>'s cgi-script handler. URLs with a case-sensitive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive (%-decoded) path beginning with <var>URL-path</var> will be mapped
fb77c505254b6e9c925e23e734463e87574f8f40kess to scripts beginning with the second argument, which is a full
fb77c505254b6e9c925e23e734463e87574f8f40kess pathname in the local filesystem.</p>
fb77c505254b6e9c925e23e734463e87574f8f40kess
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <example><title>Example:</title>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ScriptAlias /cgi-bin/ /web/cgi-bin/
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive </example>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
fb77c505254b6e9c925e23e734463e87574f8f40kess <p>A request for <code>http://myserver/cgi-bin/foo</code> would cause the
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive server to run the script <code>/web/cgi-bin/foo</code>. This configuration
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd is essentially equivalent to:</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <example>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive Alias /cgi-bin/ /web/cgi-bin/<br />
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive &lt;Location /cgi-bin &gt;<br />
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <indent>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive SetHandler cgi-script<br />
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive Options +ExecCGI<br />
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive </indent>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive &lt;/Location&gt;
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz </example>
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz
9ed9eaf871c58d281af02e76125ceadb5060afa5nd <p><directive>ScriptAlias</directive> can also be used in conjunction with
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess a script or handler you have. For example:</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz <example>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ScriptAlias /cgi-bin/ /web/cgi-handler.pl
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive </example>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>In this scenario all files requested in <code>/cgi-bin/</code> will be
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive handled by the file you have configured, this allows you to use your own custom
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive handler. You may want to use this as a wrapper for CGI so that you can add
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive content, or some other bespoke action.</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <note type="warning">It is safer to avoid placing CGI scripts under the
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <directive module="core">DocumentRoot</directive> in order to
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive avoid accidentally revealing their source code if the
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive configuration is ever changed. The
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess <directive>ScriptAlias</directive> makes this easy by mapping a
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive URL and designating CGI scripts at the same time. If you do
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem choose to place your CGI scripts in a directory already
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem accessible from the web, do not use
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem <directive>ScriptAlias</directive>. Instead, use <directive
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem module="core" type="section">Directory</directive>, <directive
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem module="core">SetHandler</directive>, and <directive
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem module="core">Options</directive> as in:
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem <example>
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem &lt;Directory /usr/local/apache2/htdocs/cgi-bin &gt;<br />
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem <indent>
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem SetHandler cgi-script<br />
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem Options ExecCGI<br />
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem </indent>
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem &lt;/Directory&gt;
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem </example>
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem This is necessary since multiple <var>URL-paths</var> can map
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem to the same filesystem location, potentially bypassing the
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem <directive>ScriptAlias</directive> and revealing the source code
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem of the CGI scripts if they are not restricted by a
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem <directive module="core">Directory</directive> section.</note>
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</usage>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<seealso><a href="/howto/cgi.html">CGI Tutorial</a></seealso>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<name>ScriptAliasMatch</name>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<description>Maps a URL to a filesystem location using a regular expression
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveand designates the target as a CGI script</description>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<syntax>ScriptAliasMatch <var>regex</var>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<var>file-path</var>|<var>directory-path</var></syntax>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<contextlist><context>server config</context><context>virtual host</context>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</contextlist>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<usage>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>This directive is equivalent to <directive module="mod_alias"
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive >ScriptAlias</directive>, but makes use of
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <glossary ref="regex">regular expressions</glossary>,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive instead of simple prefix matching. The
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive supplied regular expression is matched against the URL-path,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive and if it matches, the server will substitute any parenthesized
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive matches into the given string and use it as a filename. For
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive example, to activate the standard <code>/cgi-bin</code>, one
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive might use:</p>
9ed9eaf871c58d281af02e76125ceadb5060afa5nd
9ed9eaf871c58d281af02e76125ceadb5060afa5nd <example>
9ed9eaf871c58d281af02e76125ceadb5060afa5nd ScriptAliasMatch ^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive </example>
103a93c625bcde1a6a7a5155b64dcda36f612180pquerna</usage>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</modulesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
103a93c625bcde1a6a7a5155b64dcda36f612180pquerna