mod_alias.xml revision a502eaab6c03ce460caec304e249f013d6ed8a91
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<!--
08cb74ca432a8c24e39f17dedce527e6a47b8001jerenkrantz Licensed to the Apache Software Foundation (ASF) under one or more
08cb74ca432a8c24e39f17dedce527e6a47b8001jerenkrantz contributor license agreements. See the NOTICE file distributed with
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd this work for additional information regarding copyright ownership.
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd The ASF licenses this file to You under the Apache License, Version 2.0
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd (the "License"); you may not use this file except in compliance with
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd 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 occurring 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>
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
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna configuration will work as expected:</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <highlight language="config">
313bb560bc5c323cfd40c9cad7335b4b8e060aedkessAlias /foo/bar /baz
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAlias /foo /gaq
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive </highlight>
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 <highlight language="config">
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive Alias /image /ftp/pub/image
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive </highlight>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
fb77c505254b6e9c925e23e734463e87574f8f40kess <p>A request for <code>http://example.com/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://example.com/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
fb77c505254b6e9c925e23e734463e87574f8f40kess <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, as it lacks
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive that trailing /. Likewise, if you omit the slash on the
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <var>URL-path</var> then you must also omit it from the
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <var>file-path</var>.</p>
fb77c505254b6e9c925e23e734463e87574f8f40kess
fb77c505254b6e9c925e23e734463e87574f8f40kess <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.
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd (Note however <directive type="section" module="core">Location</directive>
130d299c4b2b15be45532a176604c71fdc7bea5bnd sections are run through once before aliases are performed, so
130d299c4b2b15be45532a176604c71fdc7bea5bnd they will apply.)</p>
130d299c4b2b15be45532a176604c71fdc7bea5bnd
130d299c4b2b15be45532a176604c71fdc7bea5bnd <p>In particular, if you are creating an <code>Alias</code> to a
130d299c4b2b15be45532a176604c71fdc7bea5bnd directory outside of your <directive
ef8e89e090461194ecadd31e8796a2c51e0531a2kess module="core">DocumentRoot</directive>, you may need to explicitly
130d299c4b2b15be45532a176604c71fdc7bea5bnd permit access to the target directory.</p>
130d299c4b2b15be45532a176604c71fdc7bea5bnd
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd <highlight language="config">
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndAlias /image /ftp/pub/image
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive&lt;Directory /ftp/pub/image&gt;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive Require all granted
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive&lt;/Directory&gt;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive </highlight>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
003f0c9fda6664daf5092a0e42f65ede20098153slive <p>Any number slashes in the <var>URL-path</var> parameter
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd matches any number of slashes in the requested URL-path.</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</usage>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<directivesynopsis>
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess<name>AliasMatch</name>
003f0c9fda6664daf5092a0e42f65ede20098153slive<description>Maps URLs to filesystem locations using regular
003f0c9fda6664daf5092a0e42f65ede20098153sliveexpressions</description>
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess<syntax>AliasMatch <var>regex</var>
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess<var>file-path</var>|<var>directory-path</var></syntax>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<contextlist><context>server config</context><context>virtual host</context>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd</contextlist>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd<usage>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>This directive is equivalent to <directive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive module="mod_alias">Alias</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, and
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if it matches, the server will substitute any parenthesized
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive 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>
130d299c4b2b15be45532a176604c71fdc7bea5bnd
130d299c4b2b15be45532a176604c71fdc7bea5bnd <highlight language="config">
130d299c4b2b15be45532a176604c71fdc7bea5bnd AliasMatch ^/icons(.*) /usr/local/apache/icons$1
130d299c4b2b15be45532a176604c71fdc7bea5bnd </highlight>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>The full range of <glossary ref="regex">regular expression</glossary>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive power is available. For example,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive it is possible to construct an alias with case-insensitive
1a3f62ca37273a15a06bb94a61d3c6fcf4bf38c9rbowen matching of the URL-path:</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <highlight language="config">
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive AliasMatch (?i)^/image(.*) /ftp/pub/image$1
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive </highlight>
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding
684f2a9a422185adda0692a1203c5ad6687fc5c5nd <p>One subtle difference
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd between <directive module="mod_alias">Alias</directive>
530eba85dbd41b8a0fa5255d3648d1440199a661slive and <directive module="mod_alias">AliasMatch</directive> is
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive that <directive module="mod_alias">Alias</directive> will
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive automatically copy any additional part of the URI, past the part
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive that matched, onto the end of the file path on the right side,
003f0c9fda6664daf5092a0e42f65ede20098153slive while <directive module="mod_alias">AliasMatch</directive> will
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive not. This means that in almost all cases, you will want the
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive regular expression to match the entire request URI from beginning
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding to end, and to use substitution on the right side.</p>
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding <p>In other words, just changing
684f2a9a422185adda0692a1203c5ad6687fc5c5nd <directive module="mod_alias">Alias</directive> to
a8ce9095d102e43fecb81093a132b90b9a227f78kess <directive module="mod_alias">AliasMatch</directive> will not
684f2a9a422185adda0692a1203c5ad6687fc5c5nd have the same effect. At a minimum, you need to
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding add <code>^</code> to the beginning of the regular expression
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding and add <code>(.*)$</code> to the end, and add <code>$1</code> to
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding the end of the replacement.</p>
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding <p>For example, suppose you want to replace this with AliasMatch:</p>
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding <highlight language="config">
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive Alias /image/ /ftp/pub/image/
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd </highlight>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd <p>This is NOT equivalent - don't do this! This will send all
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding requests that have /image/ anywhere in them to /ftp/pub/image/:</p>
684f2a9a422185adda0692a1203c5ad6687fc5c5nd
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding <highlight language="config">
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding AliasMatch /image/ /ftp/pub/image/
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding </highlight>
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding <p>This is what you need to get the same effect:</p>
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding <highlight language="config">
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding AliasMatch ^/image/(.*)$ /ftp/pub/image/$1
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding </highlight>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding <p>Of course, there's no point in
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive using <directive module="mod_alias">AliasMatch</directive>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive where <directive module="mod_alias">Alias</directive> would
58699879a562774640b95e9eedfd891f336e38c2nd work. <directive module="mod_alias">AliasMatch</directive> lets
58699879a562774640b95e9eedfd891f336e38c2nd you do more complicated things. For example, you could
58699879a562774640b95e9eedfd891f336e38c2nd serve different kinds of files from different directories:</p>
fb77c505254b6e9c925e23e734463e87574f8f40kess
fb77c505254b6e9c925e23e734463e87574f8f40kess <highlight language="config">
58699879a562774640b95e9eedfd891f336e38c2nd AliasMatch ^/image/(.*)\.jpg$ /files/jpg.images/$1.jpg<br/>
58699879a562774640b95e9eedfd891f336e38c2nd AliasMatch ^/image/(.*)\.gif$ /files/gif.images/$1.gif
58699879a562774640b95e9eedfd891f336e38c2nd </highlight>
58699879a562774640b95e9eedfd891f336e38c2nd
58699879a562774640b95e9eedfd891f336e38c2nd</usage>
58699879a562774640b95e9eedfd891f336e38c2nd</directivesynopsis>
58699879a562774640b95e9eedfd891f336e38c2nd
58699879a562774640b95e9eedfd891f336e38c2nd<directivesynopsis>
58699879a562774640b95e9eedfd891f336e38c2nd<name>Redirect</name>
58699879a562774640b95e9eedfd891f336e38c2nd<description>Sends an external redirect asking the client to fetch
58699879a562774640b95e9eedfd891f336e38c2nda different URL</description>
fb77c505254b6e9c925e23e734463e87574f8f40kess<syntax>Redirect [<var>status</var>] <var>URL-path</var>
fb77c505254b6e9c925e23e734463e87574f8f40kess<var>URL</var></syntax>
fb77c505254b6e9c925e23e734463e87574f8f40kess<contextlist><context>server config</context><context>virtual host</context>
fb77c505254b6e9c925e23e734463e87574f8f40kess<context>directory</context><context>.htaccess</context></contextlist>
fb77c505254b6e9c925e23e734463e87574f8f40kess<override>FileInfo</override>
58699879a562774640b95e9eedfd891f336e38c2nd
58699879a562774640b95e9eedfd891f336e38c2nd<usage>
58699879a562774640b95e9eedfd891f336e38c2nd <p>The Redirect directive maps an old URL into a new one by asking
58699879a562774640b95e9eedfd891f336e38c2nd the client to refetch the resource at the new location.</p>
58699879a562774640b95e9eedfd891f336e38c2nd
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess <p>The old <em>URL-path</em> is a case-sensitive (%-decoded) path
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess beginning with a slash. A relative path is not allowed.</p>
58699879a562774640b95e9eedfd891f336e38c2nd
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess <p>The new <em>URL</em> may be either an absolute URL beginning
58699879a562774640b95e9eedfd891f336e38c2nd with a scheme and hostname, or a URL-path beginning with a slash.
58699879a562774640b95e9eedfd891f336e38c2nd In this latter case the scheme and hostname of the current server will
fb77c505254b6e9c925e23e734463e87574f8f40kess be added.</p>
fb77c505254b6e9c925e23e734463e87574f8f40kess
fb77c505254b6e9c925e23e734463e87574f8f40kess <p>Then any request beginning with <em>URL-Path</em> will return a
58699879a562774640b95e9eedfd891f336e38c2nd redirect request to the client at the location of the target
58699879a562774640b95e9eedfd891f336e38c2nd <em>URL</em>. Additional path information beyond the matched
58699879a562774640b95e9eedfd891f336e38c2nd <em>URL-Path</em> will be appended to the target URL.</p>
58699879a562774640b95e9eedfd891f336e38c2nd
58699879a562774640b95e9eedfd891f336e38c2nd <highlight language="config">
58699879a562774640b95e9eedfd891f336e38c2nd# Redirect to a URL on a different host
58699879a562774640b95e9eedfd891f336e38c2ndRedirect /service http://foo2.example.com/service
58699879a562774640b95e9eedfd891f336e38c2nd
58699879a562774640b95e9eedfd891f336e38c2nd# Redirect to a URL on the same host
58699879a562774640b95e9eedfd891f336e38c2ndRedirect /one /two
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess </highlight>
4a7affccb2f1f5b94cab395e1bf3825aed715ebcnd
9b5e2c5e769dc678a1aca06df75c32022b2f1492trawick <p>If the client requests <code>http://example.com/service/foo.txt</code>,
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess it will be told to access
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess <code>http://foo2.example.com/service/foo.txt</code>
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess instead. This includes requests with <code>GET</code> parameters, such as
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess <code>http://example.com/service/foo.pl?q=23&amp;a=42</code>,
4a7affccb2f1f5b94cab395e1bf3825aed715ebcnd it will be redirected to
4a7affccb2f1f5b94cab395e1bf3825aed715ebcnd <code>http://foo2.example.com/service/foo.pl?q=23&amp;a=42</code>.
9b5e2c5e769dc678a1aca06df75c32022b2f1492trawick Note that <code>POST</code>s will be discarded.<br />
4a7affccb2f1f5b94cab395e1bf3825aed715ebcnd Only complete path segments are matched, so the above
4a7affccb2f1f5b94cab395e1bf3825aed715ebcnd example would not match a request for
4a7affccb2f1f5b94cab395e1bf3825aed715ebcnd <code>http://example.com/servicefoo.txt</code>. For more complex matching
4a7affccb2f1f5b94cab395e1bf3825aed715ebcnd using regular expressions, see the <directive
ec9b02c6869b75575ada34c800672162833a2c06nd module="mod_alias">RedirectMatch</directive> directive.</p>
58699879a562774640b95e9eedfd891f336e38c2nd
58699879a562774640b95e9eedfd891f336e38c2nd
58699879a562774640b95e9eedfd891f336e38c2nd <note><title>Note</title>
58699879a562774640b95e9eedfd891f336e38c2nd <p>Redirect directives take precedence over Alias and ScriptAlias
58699879a562774640b95e9eedfd891f336e38c2nd directives, irrespective of their ordering in the configuration
4a7affccb2f1f5b94cab395e1bf3825aed715ebcnd file.</p></note>
58699879a562774640b95e9eedfd891f336e38c2nd
58699879a562774640b95e9eedfd891f336e38c2nd <p>If no <var>status</var> argument is given, the redirect will
77ead9e0262e4f08ec336d1a65b2edef7705c839nd be "temporary" (HTTP status 302). This indicates to the client
77ead9e0262e4f08ec336d1a65b2edef7705c839nd that the resource has moved temporarily. The <var>status</var>
9583adab6bc4b3758e41963c905d9dad9f067131nd argument can be used to return other HTTP status codes:</p>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd
77ead9e0262e4f08ec336d1a65b2edef7705c839nd <dl>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd <dt>permanent</dt>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd
77ead9e0262e4f08ec336d1a65b2edef7705c839nd <dd>Returns a permanent redirect status (301) indicating that
77ead9e0262e4f08ec336d1a65b2edef7705c839nd the resource has moved permanently.</dd>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd
77ead9e0262e4f08ec336d1a65b2edef7705c839nd <dt>temp</dt>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd
77ead9e0262e4f08ec336d1a65b2edef7705c839nd <dd>Returns a temporary redirect status (302). This is the
77ead9e0262e4f08ec336d1a65b2edef7705c839nd default.</dd>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd
77ead9e0262e4f08ec336d1a65b2edef7705c839nd <dt>seeother</dt>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd
77ead9e0262e4f08ec336d1a65b2edef7705c839nd <dd>Returns a "See Other" status (303) indicating that the
77ead9e0262e4f08ec336d1a65b2edef7705c839nd resource has been replaced.</dd>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd
77ead9e0262e4f08ec336d1a65b2edef7705c839nd <dt>gone</dt>
9b5e2c5e769dc678a1aca06df75c32022b2f1492trawick
77ead9e0262e4f08ec336d1a65b2edef7705c839nd <dd>Returns a "Gone" status (410) indicating that the
77ead9e0262e4f08ec336d1a65b2edef7705c839nd resource has been permanently removed. When this status is
77ead9e0262e4f08ec336d1a65b2edef7705c839nd used the <var>URL</var> argument should be omitted.</dd>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd </dl>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd
77ead9e0262e4f08ec336d1a65b2edef7705c839nd <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
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive between 300 and 399, the <var>URL</var> argument must be present.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive If the status is <em>not</em> between 300 and 399, the
003f0c9fda6664daf5092a0e42f65ede20098153slive <var>URL</var> argument must be omitted. The status must be a valid
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess HTTP status code, known to the Apache HTTP Server (see the function
fb77c505254b6e9c925e23e734463e87574f8f40kess <code>send_error_response</code> in http_protocol.c).</p>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <highlight language="config">
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveRedirect permanent /one http://example.com/two
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveRedirect 303 /three http://example.com/other
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive </highlight>
fb77c505254b6e9c925e23e734463e87574f8f40kess
fb77c505254b6e9c925e23e734463e87574f8f40kess</usage>
fb77c505254b6e9c925e23e734463e87574f8f40kess</directivesynopsis>
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<directivesynopsis>
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess<name>RedirectMatch</name>
10673857794a4b3d9568ca2d983722a87ed352f1rbowen<description>Sends an external redirect based on a regular expression match
fb77c505254b6e9c925e23e734463e87574f8f40kessof the current URL</description>
b12b918ae6baf9c5762ed61b7393d0e2198378c0nd<syntax>RedirectMatch [<var>status</var>] <var>regex</var>
b12b918ae6baf9c5762ed61b7393d0e2198378c0nd<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 is equivalent to <directive
fb77c505254b6e9c925e23e734463e87574f8f40kess module="mod_alias">Redirect</directive>, but makes use of
fb77c505254b6e9c925e23e734463e87574f8f40kess <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
fb77c505254b6e9c925e23e734463e87574f8f40kess example, to redirect all GIF files to like-named JPEG files on
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive another server, one might use:</p>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <highlight language="config">
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive RedirectMatch (.*)\.gif$ http://other.example.com$1.jpg
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive </highlight>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>The considerations related to the difference between
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <directive module="mod_alias">Alias</directive> and
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <directive module="mod_alias">AliasMatch</directive>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive also apply to the difference between
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz <directive module="mod_alias">Redirect</directive> and
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz <directive module="mod_alias">RedirectMatch</directive>.
9ed9eaf871c58d281af02e76125ceadb5060afa5nd See <directive module="mod_alias">AliasMatch</directive> for
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess details.</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</usage>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<name>RedirectTemp</name>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<description>Sends an external temporary redirect asking the client to fetch
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivea different URL</description>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<syntax>RedirectTemp <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
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess<usage>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>This directive makes the client know that the Redirect is
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive only temporary (status 302). Exactly equivalent to
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <code>Redirect temp</code>.</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</usage>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<name>RedirectPermanent</name>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<description>Sends an external permanent redirect asking the client to fetch
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivea 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
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive permanent</code>.</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</usage>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<name>ScriptAlias</name>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<description>Maps a URL to a filesystem location and designates the
9ed9eaf871c58d281af02e76125ceadb5060afa5ndtarget as a CGI script</description>
9ed9eaf871c58d281af02e76125ceadb5060afa5nd<syntax>ScriptAlias <var>URL-path</var>
9ed9eaf871c58d281af02e76125ceadb5060afa5nd<var>file-path</var>|<var>directory-path</var></syntax>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<contextlist><context>server config</context><context>virtual host</context>
103a93c625bcde1a6a7a5155b64dcda36f612180pquerna</contextlist>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<usage>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>The <directive>ScriptAlias</directive> directive has the same
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive behavior as the <directive module="mod_alias">Alias</directive>
103a93c625bcde1a6a7a5155b64dcda36f612180pquerna directive, except that in addition it marks the target directory
103a93c625bcde1a6a7a5155b64dcda36f612180pquerna as containing CGI scripts that will be processed by <module
f23fb63b05f89f47d7a3099491f2c68dcce432e9kess >mod_cgi</module>'s cgi-script handler. URLs with a case-sensitive
f23fb63b05f89f47d7a3099491f2c68dcce432e9kess (%-decoded) path beginning with <var>URL-path</var> will be mapped
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive to scripts beginning with the second argument, which is a full
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive pathname in the local filesystem.</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <highlight language="config">
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd ScriptAlias /cgi-bin/ /web/cgi-bin/
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd </highlight>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
b12b918ae6baf9c5762ed61b7393d0e2198378c0nd <p>A request for <code>http://example.com/cgi-bin/foo</code> would cause the
b12b918ae6baf9c5762ed61b7393d0e2198378c0nd server to run the script <code>/web/cgi-bin/foo</code>. This configuration
b12b918ae6baf9c5762ed61b7393d0e2198378c0nd is essentially equivalent to:</p>
b12b918ae6baf9c5762ed61b7393d0e2198378c0nd <highlight language="config">
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAlias /cgi-bin/ /web/cgi-bin/
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive&lt;Location /cgi-bin &gt;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive SetHandler cgi-script
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive Options +ExecCGI
54bcd0e21a5c79158afd3b78bf707a493a5fb33crbowen&lt;/Location&gt;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive </highlight>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p><directive>ScriptAlias</directive> can also be used in conjunction with
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive a script or handler you have. For example:</p>
003f0c9fda6664daf5092a0e42f65ede20098153slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <highlight language="config">
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd ScriptAlias /cgi-bin/ /web/cgi-handler.pl
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive </highlight>
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
9ed9eaf871c58d281af02e76125ceadb5060afa5nd choose to place your CGI scripts in a directory already
9ed9eaf871c58d281af02e76125ceadb5060afa5nd accessible from the web, do not use
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <directive>ScriptAlias</directive>. Instead, use <directive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive module="core" type="section">Directory</directive>, <directive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive module="core">SetHandler</directive>, and <directive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive module="core">Options</directive> as in:
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd <highlight language="config">
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd&lt;Directory /usr/local/apache2/htdocs/cgi-bin &gt;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd SetHandler cgi-script
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive Options ExecCGI
1c9f7cdf2e1bc8313e559a96638c3c36e3143791yoshiki&lt;/Directory&gt;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive </highlight>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive This is necessary since multiple <var>URL-paths</var> can map
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess to the same filesystem location, potentially bypassing the
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess <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>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<seealso><a href="/howto/cgi.html">CGI Tutorial</a></seealso>
003f0c9fda6664daf5092a0e42f65ede20098153slive</directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<directivesynopsis>
530eba85dbd41b8a0fa5255d3648d1440199a661slive<name>ScriptAliasMatch</name>
530eba85dbd41b8a0fa5255d3648d1440199a661slive<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>
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess</contextlist>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<usage>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>This directive is equivalent to <directive module="mod_alias"
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive >ScriptAlias</directive>, but makes use of
9ed9eaf871c58d281af02e76125ceadb5060afa5nd <glossary ref="regex">regular expressions</glossary>,
9ed9eaf871c58d281af02e76125ceadb5060afa5nd 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>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes <highlight language="config">
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes ScriptAliasMatch ^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
fb77c505254b6e9c925e23e734463e87574f8f40kess </highlight>
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes
fb77c505254b6e9c925e23e734463e87574f8f40kess <p>As for AliasMatch, the full range of <glossary ref="rexex">regular
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes expression</glossary> power is available.
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes For example, it is possible to construct an alias with case-insensitive
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes matching of the URL-path:</p>
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes <highlight language="config">
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes ScriptAliasMatch (?i)^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes </highlight>
fb77c505254b6e9c925e23e734463e87574f8f40kess
fb77c505254b6e9c925e23e734463e87574f8f40kess <p>The considerations related to the difference between
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess <directive module="mod_alias">Alias</directive> and
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess <directive module="mod_alias">AliasMatch</directive>
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes also apply to the difference between
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes <directive module="mod_alias">ScriptAlias</directive> and
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes <directive module="mod_alias">ScriptAliasMatch</directive>.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive See <directive module="mod_alias">AliasMatch</directive> for
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive details.</p>
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess
fb77c505254b6e9c925e23e734463e87574f8f40kess</usage>
fb77c505254b6e9c925e23e734463e87574f8f40kess</directivesynopsis>
fb77c505254b6e9c925e23e734463e87574f8f40kess
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</modulesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive