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
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen <directive module="mod_alias">Alias</directive> and <directive
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen 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
e4e60c2f7ba8f12b687f588b89e413842e9f2d76igalic module="core">DocumentRoot</directive> served as part of the web
e4e60c2f7ba8f12b687f588b89e413842e9f2d76igalic document tree. The <directive
e4e60c2f7ba8f12b687f588b89e413842e9f2d76igalic module="mod_alias">ScriptAlias</directive> directive has the
e4e60c2f7ba8f12b687f588b89e413842e9f2d76igalic additional effect of marking the target directory as containing
e4e60c2f7ba8f12b687f588b89e413842e9f2d76igalic only CGI scripts.</p>
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe <p>The <directive module="mod_alias">Redirect</directive>
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe directives are used to instruct clients to make a new request with
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe a different URL. They are often used when a resource has moved to
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor a new location.</p>
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe <p><module>mod_alias</module> is designed to handle simple URL
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe manipulation tasks. For more complicated tasks such as
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna manipulating the query string, use the tools provided by
4e9f8c5414e5fe39b5393641533edca65f6e8b91poirier <module>mod_rewrite</module>.</p>
4e9f8c5414e5fe39b5393641533edca65f6e8b91poirier
4e9f8c5414e5fe39b5393641533edca65f6e8b91poirier</summary>
4e9f8c5414e5fe39b5393641533edca65f6e8b91poirier
4e9f8c5414e5fe39b5393641533edca65f6e8b91poirier<seealso><module>mod_rewrite</module></seealso> <seealso><a
4e9f8c5414e5fe39b5393641533edca65f6e8b91poirierhref="/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
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor href="/sections.html#mergin">merging rules</a>. But when multiple
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna Aliases or Redirects occur in the same context (for example, in the
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor same <directive type="section" module="core">VirtualHost</directive>
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor section) they are processed in a particular order.</p>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor <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>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna
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
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor configuration will work as expected:</p>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor <example>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna Alias /foo/bar /baz<br />
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna Alias /foo /gaq
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna </example>
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe <p>But if the above two directives were reversed in order, the
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe <code>/foo</code> <directive module="mod_alias">Alias</directive>
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe would always match before the <code>/foo/bar</code> <directive
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe module="mod_alias">Alias</directive>, so the latter directive would be
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe ignored.</p>
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe</section>
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe<directivesynopsis>
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe<name>Alias</name>
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe<description>Maps URLs to filesystem locations</description>
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe<syntax>Alias <var>URL-path</var>
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe<var>file-path</var>|<var>directory-path</var></syntax>
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe<contextlist><context>server config</context><context>virtual host</context>
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe</contextlist>
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe
e4e60c2f7ba8f12b687f588b89e413842e9f2d76igalic<usage>
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe <p>The <directive>Alias</directive> directive allows documents to
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe be stored in the local filesystem other than under the
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor <directive module="core">DocumentRoot</directive>. URLs with a
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna (%-decoded) path beginning with <var>url-path</var> will be mapped
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna to local files beginning with <var>directory-path</var>. The
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen <var>url-path</var> is case-sensitive, even on case-insensitive
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna file systems.</p>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <example><title>Example:</title>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive Alias /image /ftp/pub/image
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess </example>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <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
18b4b0fd6056093002ddef488636bf5ebe415ef0erikabele matching using regular expressions, see the <directive module="mod_alias"
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen >AliasMatch</directive> directive.</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>Note that if you include a trailing / on the
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <var>url-path</var> then the server will require a trailing / in
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive order to expand the alias. That is, if you use</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <dl><dd><code>Alias /icons/ /usr/local/apache/icons/</code></dd></dl>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
fb77c505254b6e9c925e23e734463e87574f8f40kess <p>then the url <code>/icons</code> will not be aliased.</p>
fb77c505254b6e9c925e23e734463e87574f8f40kess
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>Note that you may need to specify additional <directive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive type="section" module="core">Directory</directive> sections which
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive cover the <em>destination</em> of aliases. Aliasing occurs before
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <directive type="section" module="core">Directory</directive> sections
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive are checked, so only the destination of aliases are affected.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive (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>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>In particular, if you are creating an <code>Alias</code> to a
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive directory outside of your <directive
fb77c505254b6e9c925e23e734463e87574f8f40kess module="core">DocumentRoot</directive>, you may need to explicitly
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive permit access to the target directory.</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <example><title>Example:</title>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive Alias /image /ftp/pub/image<br />
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive &lt;Directory /ftp/pub/image&gt;<br />
fb77c505254b6e9c925e23e734463e87574f8f40kess <indent>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive Order allow,deny<br />
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive Allow from all<br />
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive </indent>
fb77c505254b6e9c925e23e734463e87574f8f40kess &lt;/Directory&gt;
fb77c505254b6e9c925e23e734463e87574f8f40kess </example>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</usage>
fb77c505254b6e9c925e23e734463e87574f8f40kess</directivesynopsis>
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<directivesynopsis>
bc4b55ec8f31569d606d5680d50189a355bcd7a6rbowen<name>AliasMatch</name>
fb77c505254b6e9c925e23e734463e87574f8f40kess<description>Maps URLs to filesystem locations using regular
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveexpressions</description>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<syntax>AliasMatch <var>regex</var>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<var>file-path</var>|<var>directory-path</var></syntax>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<contextlist><context>server config</context><context>virtual host</context>
fb77c505254b6e9c925e23e734463e87574f8f40kess</contextlist>
fb77c505254b6e9c925e23e734463e87574f8f40kess
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<usage>
fb77c505254b6e9c925e23e734463e87574f8f40kess <p>This directive is equivalent to <directive
fb77c505254b6e9c925e23e734463e87574f8f40kess module="mod_alias">Alias</directive>, but makes use of
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <glossary ref="regex">regular expressions</glossary>,
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd instead of simple prefix matching. The
130d299c4b2b15be45532a176604c71fdc7bea5bnd supplied regular expression is matched against the URL-path, and
130d299c4b2b15be45532a176604c71fdc7bea5bnd if it matches, the server will substitute any parenthesized
130d299c4b2b15be45532a176604c71fdc7bea5bnd matches into the given string and use it as a filename. For
130d299c4b2b15be45532a176604c71fdc7bea5bnd example, to activate the <code>/icons</code> directory, one might
130d299c4b2b15be45532a176604c71fdc7bea5bnd use:</p>
ef8e89e090461194ecadd31e8796a2c51e0531a2kess
130d299c4b2b15be45532a176604c71fdc7bea5bnd <example>
130d299c4b2b15be45532a176604c71fdc7bea5bnd AliasMatch ^/icons(.*) /usr/local/apache/icons$1
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd </example>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>It is also possible to construct an alias with case-insensitive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive matching of the url-path:</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <example>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive AliasMatch (?i)^/image(.*) /ftp/pub/image$1
003f0c9fda6664daf5092a0e42f65ede20098153slive </example>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</usage>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<name>Redirect</name>
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess<description>Sends an external redirect asking the client to fetch
003f0c9fda6664daf5092a0e42f65ede20098153slivea different URL</description>
003f0c9fda6664daf5092a0e42f65ede20098153slive<syntax>Redirect [<var>status</var>] <var>URL-path</var>
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess<var>URL</var></syntax>
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess<contextlist><context>server config</context><context>virtual host</context>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<context>directory</context><context>.htaccess</context></contextlist>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd<override>FileInfo</override>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd<usage>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>The Redirect directive maps an old URL into a new one by asking
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive the client to refetch the resource at the new location.</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>The old <em>URL-path</em> is a case-sensitive (%-decoded) path
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive beginning with a slash. A relative path is not allowed.</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>The new <em>URL</em> may be either an absolute URL beginning
130d299c4b2b15be45532a176604c71fdc7bea5bnd with a scheme and hostname, or a URL-path beginning with a slash.
130d299c4b2b15be45532a176604c71fdc7bea5bnd In this latter case the scheme and hostname of the current server will
130d299c4b2b15be45532a176604c71fdc7bea5bnd be added.</p>
130d299c4b2b15be45532a176604c71fdc7bea5bnd
130d299c4b2b15be45532a176604c71fdc7bea5bnd <p>Then any request beginning with <em>URL-Path</em> will return a
130d299c4b2b15be45532a176604c71fdc7bea5bnd redirect request to the client at the location of the target
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd <em>URL</em>. Additional path information beyond the matched
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <em>URL-Path</em> will be appended to the target URL.</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <example><title>Example:</title>
1a3f62ca37273a15a06bb94a61d3c6fcf4bf38c9rbowen Redirect /service http://foo2.example.com/service<br />
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <br />
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive # Redirect to a URL on the same host<br />
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive Redirect /one /two
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive </example>
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding
684f2a9a422185adda0692a1203c5ad6687fc5c5nd <p>If the client requests <code>http://example.com/service/foo.txt</code>,
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd it will be told to access
530eba85dbd41b8a0fa5255d3648d1440199a661slive <code>http://foo2.example.com/service/foo.txt</code>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive instead. Only complete path segments are matched, so the above
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive example would not match a request for
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <code>http://example.com/servicefoo.txt</code>. For more complex matching
003f0c9fda6664daf5092a0e42f65ede20098153slive using regular expressions, see the <directive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive module="mod_alias">RedirectMatch</directive> directive.</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding <note><title>Note</title>
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding <p>Redirect directives take precedence over Alias and ScriptAlias
684f2a9a422185adda0692a1203c5ad6687fc5c5nd directives, irrespective of their ordering in the configuration
a8ce9095d102e43fecb81093a132b90b9a227f78kess file.</p></note>
684f2a9a422185adda0692a1203c5ad6687fc5c5nd
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding <p>If no <var>status</var> argument is given, the redirect will
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding be "temporary" (HTTP status 302). This indicates to the client
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding that the resource has moved temporarily. The <var>status</var>
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding argument can be used to return other HTTP status codes:</p>
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding <dl>
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding <dt>permanent</dt>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd <dd>Returns a permanent redirect status (301) indicating that
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd the resource has moved permanently.</dd>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding <dt>temp</dt>
684f2a9a422185adda0692a1203c5ad6687fc5c5nd
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding <dd>Returns a temporary redirect status (302). This is the
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding default.</dd>
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding <dt>seeother</dt>
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding <dd>Returns a "See Other" status (303) indicating that the
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding resource has been replaced.</dd>
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding <dt>gone</dt>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding <dd>Returns a "Gone" status (410) indicating that the
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive resource has been permanently removed. When this status is
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive used the <var>URL</var> argument should be omitted.</dd>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd </dl>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd
9583adab6bc4b3758e41963c905d9dad9f067131nd <p>Other status codes can be returned by giving the numeric
77ead9e0262e4f08ec336d1a65b2edef7705c839nd status code as the value of <var>status</var>. If the status is
77ead9e0262e4f08ec336d1a65b2edef7705c839nd between 300 and 399, the <var>URL</var> argument must be present,
77ead9e0262e4f08ec336d1a65b2edef7705c839nd otherwise it must be omitted. Note that the status must be
77ead9e0262e4f08ec336d1a65b2edef7705c839nd known to the Apache code (see the function
77ead9e0262e4f08ec336d1a65b2edef7705c839nd <code>send_error_response</code> in http_protocol.c).</p>
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen
77ead9e0262e4f08ec336d1a65b2edef7705c839nd <example><title>Example:</title>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd Redirect permanent /one http://example.com/two<br />
77ead9e0262e4f08ec336d1a65b2edef7705c839nd Redirect 303 /three http://example.com/other
77ead9e0262e4f08ec336d1a65b2edef7705c839nd </example>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd
77ead9e0262e4f08ec336d1a65b2edef7705c839nd</usage>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd</directivesynopsis>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd
77ead9e0262e4f08ec336d1a65b2edef7705c839nd<directivesynopsis>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd<name>RedirectMatch</name>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd<description>Sends an external redirect based on a regular expression match
77ead9e0262e4f08ec336d1a65b2edef7705c839ndof the current URL</description>
9b5e2c5e769dc678a1aca06df75c32022b2f1492trawick<syntax>RedirectMatch [<var>status</var>] <var>regex</var>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd<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 is equivalent to <directive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive module="mod_alias">Redirect</directive>, but makes use of
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <glossary ref="regex">regular expressions</glossary>,
003f0c9fda6664daf5092a0e42f65ede20098153slive instead of simple prefix matching. The
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess supplied regular expression is matched against the URL-path, and
fb77c505254b6e9c925e23e734463e87574f8f40kess if it matches, the server will substitute any parenthesized
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd matches into the given string and use it as a filename. For
4ea161d94782fa56f4b36d496f35ff8577c43065covener example, to redirect all GIF files to like-named JPEG files on
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive another server, one might use:</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <example>
fb77c505254b6e9c925e23e734463e87574f8f40kess RedirectMatch (.*)\.gif$ http://www.anotherserver.com$1.jpg
fb77c505254b6e9c925e23e734463e87574f8f40kess </example>
fb77c505254b6e9c925e23e734463e87574f8f40kess</usage>
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess</directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess<directivesynopsis>
10673857794a4b3d9568ca2d983722a87ed352f1rbowen<name>RedirectTemp</name>
fb77c505254b6e9c925e23e734463e87574f8f40kess<description>Sends an external temporary redirect asking the client to fetch
b12b918ae6baf9c5762ed61b7393d0e2198378c0nda different URL</description>
b12b918ae6baf9c5762ed61b7393d0e2198378c0nd<syntax>RedirectTemp <var>URL-path</var> <var>URL</var></syntax>
b12b918ae6baf9c5762ed61b7393d0e2198378c0nd<contextlist><context>server config</context><context>virtual host</context>
b12b918ae6baf9c5762ed61b7393d0e2198378c0nd<context>directory</context><context>.htaccess</context></contextlist>
10673857794a4b3d9568ca2d983722a87ed352f1rbowen<override>FileInfo</override>
10673857794a4b3d9568ca2d983722a87ed352f1rbowen
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<usage>
fb77c505254b6e9c925e23e734463e87574f8f40kess <p>This directive makes the client know that the Redirect is
fb77c505254b6e9c925e23e734463e87574f8f40kess only temporary (status 302). Exactly equivalent to
fb77c505254b6e9c925e23e734463e87574f8f40kess <code>Redirect temp</code>.</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</usage>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<directivesynopsis>
fb77c505254b6e9c925e23e734463e87574f8f40kess<name>RedirectPermanent</name>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<description>Sends an external permanent redirect asking the client to fetch
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnda different URL</description>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<syntax>RedirectPermanent <var>URL-path</var> <var>URL</var></syntax>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<contextlist><context>server config</context><context>virtual host</context>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<context>directory</context><context>.htaccess</context></contextlist>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<override>FileInfo</override>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<usage>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>This directive makes the client know that the Redirect is
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive permanent (status 301). Exactly equivalent to <code>Redirect
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz permanent</code>.</p>
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz</usage>
9ed9eaf871c58d281af02e76125ceadb5060afa5nd</directivesynopsis>
9cd3b05d7b70f07a742bbaf548fa4fa2bdbe5ce6noodl
9cd3b05d7b70f07a742bbaf548fa4fa2bdbe5ce6noodl<directivesynopsis>
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz<name>ScriptAlias</name>
9cd3b05d7b70f07a742bbaf548fa4fa2bdbe5ce6noodl<description>Maps a URL to a filesystem location and designates the
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivetarget as a CGI script</description>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<syntax>ScriptAlias <var>URL-path</var>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<var>file-path</var>|<var>directory-path</var></syntax>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<contextlist><context>server config</context><context>virtual host</context>
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding</contextlist>
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding<usage>
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding <p>The <directive>ScriptAlias</directive> directive has the same
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding behavior as the <directive module="mod_alias">Alias</directive>
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding directive, except that in addition it marks the target directory
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding as containing CGI scripts that will be processed by <module
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding >mod_cgi</module>'s cgi-script handler. URLs with a case-sensitive
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding (%-decoded) path beginning with <var>URL-path</var> will be mapped
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem to scripts beginning with the second argument, which is a full
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem pathname in the local filesystem.</p>
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem <example><title>Example:</title>
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem ScriptAlias /cgi-bin/ /web/cgi-bin/
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem </example>
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem <p>A request for <code>http://myserver/cgi-bin/foo</code> would cause the
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem server to run the script <code>/web/cgi-bin/foo</code>. This configuration
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem is essentially equivalent to:</p>
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem <example>
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem Alias /cgi-bin/ /web/cgi-bin/<br />
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem &lt;Location /cgi-bin &gt;<br />
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem <indent>
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem SetHandler cgi-script<br />
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem Options +ExecCGI<br />
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem </indent>
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem &lt;/Location&gt;
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem </example>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p><directive>ScriptAlias</directive> can also be used in conjunction with
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive a script or handler you have. For example:</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <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
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <directive>ScriptAlias</directive> makes this easy by mapping a
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive URL and designating CGI scripts at the same time. If you do
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive choose to place your CGI scripts in a directory already
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive accessible from the web, do not use
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <directive>ScriptAlias</directive>. Instead, use <directive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive module="core" type="section">Directory</directive>, <directive
9ed9eaf871c58d281af02e76125ceadb5060afa5nd module="core">SetHandler</directive>, and <directive
9ed9eaf871c58d281af02e76125ceadb5060afa5nd module="core">Options</directive> as in:
9ed9eaf871c58d281af02e76125ceadb5060afa5nd <example>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive &lt;Directory /usr/local/apache2/htdocs/cgi-bin &gt;<br />
103a93c625bcde1a6a7a5155b64dcda36f612180pquerna <indent>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive SetHandler cgi-script<br />
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive Options ExecCGI<br />
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive </indent>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive &lt;/Directory&gt;
103a93c625bcde1a6a7a5155b64dcda36f612180pquerna </example>
103a93c625bcde1a6a7a5155b64dcda36f612180pquerna This is necessary since multiple <var>URL-paths</var> can map
f23fb63b05f89f47d7a3099491f2c68dcce432e9kess to the same filesystem location, potentially bypassing the
f23fb63b05f89f47d7a3099491f2c68dcce432e9kess <directive>ScriptAlias</directive> and revealing the source code
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive of the CGI scripts if they are not restricted by a
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <directive module="core">Directory</directive> section.</note>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</usage>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd<seealso><a href="/howto/cgi.html">CGI Tutorial</a></seealso>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd</directivesynopsis>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
b12b918ae6baf9c5762ed61b7393d0e2198378c0nd<directivesynopsis>
b12b918ae6baf9c5762ed61b7393d0e2198378c0nd<name>ScriptAliasMatch</name>
b12b918ae6baf9c5762ed61b7393d0e2198378c0nd<description>Maps a URL to a filesystem location using a regular expression
b12b918ae6baf9c5762ed61b7393d0e2198378c0ndand designates the target as a CGI script</description>
da637bcae7b6e150470e701af29da5604a34a17erbowen<syntax>ScriptAliasMatch <var>regex</var>
da637bcae7b6e150470e701af29da5604a34a17erbowen<var>file-path</var>|<var>directory-path</var></syntax>
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor<contextlist><context>server config</context><context>virtual host</context>
da637bcae7b6e150470e701af29da5604a34a17erbowen</contextlist>
da637bcae7b6e150470e701af29da5604a34a17erbowen
da637bcae7b6e150470e701af29da5604a34a17erbowen<usage>
da637bcae7b6e150470e701af29da5604a34a17erbowen <p>This directive is equivalent to <directive module="mod_alias"
da637bcae7b6e150470e701af29da5604a34a17erbowen >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
54bcd0e21a5c79158afd3b78bf707a493a5fb33crbowen 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>
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes <example>
fb77c505254b6e9c925e23e734463e87574f8f40kess ScriptAliasMatch ^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes </example>
fb77c505254b6e9c925e23e734463e87574f8f40kess</usage>
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes</directivesynopsis>
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes</modulesynopsis>
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes