mod_alias.xml revision e32abf00422bf50d92c28c448f60b951c8fa42ea
530eba85dbd41b8a0fa5255d3648d1440199a661slive<!DOCTYPE modulesynopsis SYSTEM "/style/modulesynopsis.dtd">
e942c741056732f50da2074b36fe59805d370650slive<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
5f5d1b4cc970b7f06ff8ef6526128e9a27303d88nd<!-- $LastChangedRevision$ -->
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 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.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<description>Provides for mapping different parts of the host
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive filesystem in the document tree and for URL redirection</description>
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 <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 <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<seealso><module>mod_rewrite</module></seealso> <seealso><a
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquernahref="/urlmapping.html">Mapping URLs to the filesystem</a></seealso>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna<section id="order"><title>Order of Processing</title>
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 <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 <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 Alias /foo /gaq
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<directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<description>Maps URLs to filesystem locations</description>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<contextlist><context>server config</context><context>virtual host</context>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</contextlist>
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>
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"
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>
bc4b55ec8f31569d606d5680d50189a355bcd7a6rbowen <dl><dd><code>Alias /icons/ /usr/local/apache/icons/</code></dd></dl>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>then the url <code>/icons</code> will not be aliased.</p>
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>
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>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd Order allow,deny<br />
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive Allow from all<br />
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive </Directory>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd</directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<description>Maps URLs to filesystem locations using regular
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveexpressions</description>
003f0c9fda6664daf5092a0e42f65ede20098153slive<var>file-path</var>|<var>directory-path</var></syntax>
003f0c9fda6664daf5092a0e42f65ede20098153slive<contextlist><context>server config</context><context>virtual host</context>
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess</contextlist>
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
130d299c4b2b15be45532a176604c71fdc7bea5bnd </example>
130d299c4b2b15be45532a176604c71fdc7bea5bnd <p>It is also possible to construct an alias with case-insensitive
130d299c4b2b15be45532a176604c71fdc7bea5bnd matching of the url-path:</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<directivesynopsis>
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<contextlist><context>server config</context><context>virtual host</context>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<context>directory</context><context>.htaccess</context></contextlist>
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>
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>
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 <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>
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding Redirect /service http://foo2.example.com/service<br />
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding # Redirect to a URL on the same host<br />
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding Redirect /one /two
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>
58699879a562774640b95e9eedfd891f336e38c2nd <p>Redirect directives take precedence over Alias and ScriptAlias
fb77c505254b6e9c925e23e734463e87574f8f40kess directives, irrespective of their ordering in the configuration
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>
a2920e90d95fa04c15bdbbc03e7f8636eac92423slive <dd>Returns a permanent redirect status (301) indicating that
a2920e90d95fa04c15bdbbc03e7f8636eac92423slive the resource has moved permanently.</dd>
fb77c505254b6e9c925e23e734463e87574f8f40kess <dd>Returns a temporary redirect status (302). This is the
fb77c505254b6e9c925e23e734463e87574f8f40kess default.</dd>
58699879a562774640b95e9eedfd891f336e38c2nd <dd>Returns a "See Other" status (303) indicating that the
58699879a562774640b95e9eedfd891f336e38c2nd resource has been replaced.</dd>
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>
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 Redirect 303 /three http://example.com/other
58699879a562774640b95e9eedfd891f336e38c2nd </example>
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess</directivesynopsis>
9b5e2c5e769dc678a1aca06df75c32022b2f1492trawick<directivesynopsis>
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<contextlist><context>server config</context><context>virtual host</context>
9b5e2c5e769dc678a1aca06df75c32022b2f1492trawick<context>directory</context><context>.htaccess</context></contextlist>
ec9b02c6869b75575ada34c800672162833a2c06nd module="mod_alias">Redirect</directive>, but makes use of
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>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd RedirectMatch (.*)\.gif$ http://www.anotherserver.com$1.jpg
9583adab6bc4b3758e41963c905d9dad9f067131nd </example>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd</directivesynopsis>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd<directivesynopsis>
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 <p>This directive makes the client know that the Redirect is
77ead9e0262e4f08ec336d1a65b2edef7705c839nd only temporary (status 302). Exactly equivalent to
77ead9e0262e4f08ec336d1a65b2edef7705c839nd</directivesynopsis>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd<directivesynopsis>
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>
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess <p>This directive makes the client know that the Redirect is
fb77c505254b6e9c925e23e734463e87574f8f40kess permanent (status 301). Exactly equivalent to <code>Redirect
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<directivesynopsis>
fb77c505254b6e9c925e23e734463e87574f8f40kess<description>Maps a URL to a filesystem location and designates the
fb77c505254b6e9c925e23e734463e87574f8f40kesstarget as a CGI script</description>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<var>file-path</var>|<var>directory-path</var></syntax>
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess<contextlist><context>server config</context><context>virtual host</context>
10673857794a4b3d9568ca2d983722a87ed352f1rbowen</contextlist>
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 <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 <Location /cgi-bin ><br />
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive SetHandler cgi-script<br />
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive Options +ExecCGI<br />
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive </Location>
9ed9eaf871c58d281af02e76125ceadb5060afa5nd <p><directive>ScriptAlias</directive> can also be used in conjunction with
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess a script or handler you have. For example:</p>
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 <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 <Directory /usr/local/apache2/htdocs/cgi-bin ><br />
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem SetHandler cgi-script<br />
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem Options ExecCGI<br />
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem </Directory>
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>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<seealso><a href="/howto/cgi.html">CGI Tutorial</a></seealso>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<description>Maps a URL to a filesystem location using a regular expression
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveand designates the target as a CGI script</description>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<var>file-path</var>|<var>directory-path</var></syntax>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<contextlist><context>server config</context><context>virtual host</context>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</contextlist>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>This directive is equivalent to <directive module="mod_alias"
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive >ScriptAlias</directive>, but makes use of
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 ScriptAliasMatch ^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</modulesynopsis>