mod_alias.xml revision 6e87cc731ab01e065173ae8cc7152751d0387122
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
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>
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 <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<seealso><module>mod_rewrite</module></seealso> <seealso><a
4e9f8c5414e5fe39b5393641533edca65f6e8b91poirierhref="/urlmapping.html">Mapping URLs to the filesystem</a></seealso>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna<section id="order"><title>Order of Processing</title>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna <p>Aliases and Redirects occurring 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>
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 <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 Alias /foo /gaq
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<directivesynopsis>
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe<description>Maps URLs to filesystem locations</description>
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe<var>file-path</var>|<var>directory-path</var></syntax>
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe<contextlist><context>server config</context><context>virtual host</context>
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe</contextlist>
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>
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess </example>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <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
18b4b0fd6056093002ddef488636bf5ebe415ef0erikabele matching using regular expressions, see the <directive module="mod_alias"
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 <dl><dd><code>Alias /icons/ /usr/local/apache/icons/</code></dd></dl>
fb77c505254b6e9c925e23e734463e87574f8f40kess <p>then the url <code>/icons</code> will not be aliased, as it lacks
fb77c505254b6e9c925e23e734463e87574f8f40kess that trailing /. Likewise, if you omit the slash on the
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <var>url-path</var> then you must also omit it from the
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
fb77c505254b6e9c925e23e734463e87574f8f40kess <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>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive sections are run through once before aliases are performed, so
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive they will apply.)</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>In particular, if you are creating an <code>Alias</code> to a
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive directory outside of your <directive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive module="core">DocumentRoot</directive>, you may need to explicitly
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive permit access to the target directory.</p>
fb77c505254b6e9c925e23e734463e87574f8f40kess Require all granted<br />
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive </Directory>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</directivesynopsis>
fb77c505254b6e9c925e23e734463e87574f8f40kess<directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<description>Maps URLs to filesystem locations using regular
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveexpressions</description>
fb77c505254b6e9c925e23e734463e87574f8f40kess<contextlist><context>server config</context><context>virtual host</context>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</contextlist>
130d299c4b2b15be45532a176604c71fdc7bea5bnd 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
ef8e89e090461194ecadd31e8796a2c51e0531a2kess example, to activate the <code>/icons</code> directory, one might
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
003f0c9fda6664daf5092a0e42f65ede20098153slive matching of the url-path:</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>One subtle difference
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess between <directive module="mod_alias">Alias</directive>
003f0c9fda6664daf5092a0e42f65ede20098153slive and <directive module="mod_alias">AliasMatch</directive> is
003f0c9fda6664daf5092a0e42f65ede20098153slive that <directive module="mod_alias">Alias</directive> will
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess automatically copy any additional part of the URI, past the part
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess that matched, onto the end of the file path on the right side,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive while <directive module="mod_alias">AliasMatch</directive> will
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd not. This means that in almost all cases, you will want the
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd regular expression to match the entire request URI from beginning
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd to end, and to use substitution on the right side.</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>In other words, just changing
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <directive module="mod_alias">AliasMatch</directive> will not
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive have the same effect. At a minimum, you need to
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive add <code>^</code> to the beginning of the regular expression
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive and add <code>(.*)$</code> to the end, and add <code>$1</code> to
130d299c4b2b15be45532a176604c71fdc7bea5bnd the end of the replacement.</p>
130d299c4b2b15be45532a176604c71fdc7bea5bnd <p>For example, suppose you want to replace this with AliasMatch:</p>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd </example>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>This is NOT equivalent - don't do this! This will send all
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive requests that have /image/ anywhere in them to /ftp/pub/image/:</p>
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding <p>This is what you need to get the same effect:</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>Of course, there's no point in
003f0c9fda6664daf5092a0e42f65ede20098153slive using <directive module="mod_alias">AliasMatch</directive>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive where <directive module="mod_alias">Alias</directive> would
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive work. <directive module="mod_alias">AliasMatch</directive> lets
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding you do more complicated things. For example, you could
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding serve different kinds of files from different directories:</p>
a8ce9095d102e43fecb81093a132b90b9a227f78kess AliasMatch ^/image/(.*)\.jpg$ /files/jpg.images/$1.jpg<br/>
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding</directivesynopsis>
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding<directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<description>Sends an external redirect asking the client to fetch
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnda different URL</description>
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding<contextlist><context>server config</context><context>virtual host</context>
684f2a9a422185adda0692a1203c5ad6687fc5c5nd<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>
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding <p>The old <em>URL-path</em> is a case-sensitive (%-decoded) path
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding beginning with a slash. A relative path is not allowed.</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <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.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive In this latter case the scheme and hostname of the current server will
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive be added.</p>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd <p>Then any request beginning with <em>URL-Path</em> will return a
9583adab6bc4b3758e41963c905d9dad9f067131nd redirect request to the client at the location of the target
77ead9e0262e4f08ec336d1a65b2edef7705c839nd <em>URL</em>. Additional path information beyond the matched
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier <em>URL-Path</em> will be appended to the target URL.</p>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd # Redirect to a URL on a different host<br />
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier Redirect /service http://foo2.example.com/service<br />
77ead9e0262e4f08ec336d1a65b2edef7705c839nd # Redirect to a URL on the same host<br />
77ead9e0262e4f08ec336d1a65b2edef7705c839nd Redirect /one /two
77ead9e0262e4f08ec336d1a65b2edef7705c839nd </example>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd <p>If the client requests <code>http://example.com/service/foo.txt</code>,
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier it will be told to access
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier <code>http://foo2.example.com/service/foo.txt</code>
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier instead. This includes requests with <code>GET</code> parameters, such as
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier <code>http://example.com/service/foo.pl?q=23&a=42</code>,
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier it will be redirected to
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier <code>http://foo2.example.com/service/foo.pl?q=23&a=42</code>.
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier Note that <code>POST</code>s will be discarded.<br />
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier Only complete path segments are matched, so the above
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier example would not match a request for
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier <code>http://example.com/servicefoo.txt</code>. For more complex matching
77ead9e0262e4f08ec336d1a65b2edef7705c839nd using regular expressions, see the <directive
77ead9e0262e4f08ec336d1a65b2edef7705c839nd module="mod_alias">RedirectMatch</directive> directive.</p>
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier <p>Redirect directives take precedence over Alias and ScriptAlias
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier directives, irrespective of their ordering in the configuration
77ead9e0262e4f08ec336d1a65b2edef7705c839nd <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>
77ead9e0262e4f08ec336d1a65b2edef7705c839nd argument can be used to return other HTTP status codes:</p>
fb77c505254b6e9c925e23e734463e87574f8f40kess <dd>Returns a permanent redirect status (301) indicating that
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd the resource has moved permanently.</dd>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <dd>Returns a temporary redirect status (302). This is the
fb77c505254b6e9c925e23e734463e87574f8f40kess default.</dd>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <dd>Returns a "See Other" status (303) indicating that the
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess resource has been replaced.</dd>
b12b918ae6baf9c5762ed61b7393d0e2198378c0nd <dd>Returns a "Gone" status (410) indicating that the
b12b918ae6baf9c5762ed61b7393d0e2198378c0nd resource has been permanently removed. When this status is
113961f0559eb026ea0d379cb7350f82bc09d710druggeri <p>Other status codes can be returned by giving the numeric
113961f0559eb026ea0d379cb7350f82bc09d710druggeri status code as the value of <var>status</var>. If the status is
113961f0559eb026ea0d379cb7350f82bc09d710druggeri between 300 and 399, the <var>URL</var> argument must be present.
113961f0559eb026ea0d379cb7350f82bc09d710druggeri If the status is <em>not</em> between 300 and 399, the
113961f0559eb026ea0d379cb7350f82bc09d710druggeri <var>URL</var> argument must be omitted. The status must be a valid
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive HTTP status code, known to the Apache HTTP Server (see the function
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <code>send_error_response</code> in http_protocol.c).</p>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive Redirect 303 /three http://example.com/other
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd </example>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<description>Sends an external redirect based on a regular expression match
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveof the current URL</description>
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz<syntax>RedirectMatch [<var>status</var>] <var>regex</var>
9ed9eaf871c58d281af02e76125ceadb5060afa5nd<contextlist><context>server config</context><context>virtual host</context>
9cd3b05d7b70f07a742bbaf548fa4fa2bdbe5ce6noodl<context>directory</context><context>.htaccess</context></contextlist>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive module="mod_alias">Redirect</directive>, but makes use of
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive instead of simple prefix matching. The
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding supplied regular expression is matched against the URL-path, and
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding if it matches, the server will substitute any parenthesized
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding matches into the given string and use it as a filename. For
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding example, to redirect all GIF files to like-named JPEG files on
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding another server, one might use:</p>
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding RedirectMatch (.*)\.gif$ http://other.example.com$1.jpg
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem <p>The considerations related to the difference between
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem also apply to the difference between
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem <directive module="mod_alias">Redirect</directive> and
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem <directive module="mod_alias">RedirectMatch</directive>.
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem See <directive module="mod_alias">AliasMatch</directive> for
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem details.</p>
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem</directivesynopsis>
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem<directivesynopsis>
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem<description>Sends an external temporary redirect asking the client to fetch
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluema different URL</description>
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem<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 <p>This directive makes the client know that the Redirect is
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive only temporary (status 302). Exactly equivalent to
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive</directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<directivesynopsis>
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 <p>This directive makes the client know that the Redirect is
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive permanent (status 301). Exactly equivalent to <code>Redirect
9ed9eaf871c58d281af02e76125ceadb5060afa5nd</directivesynopsis>
103a93c625bcde1a6a7a5155b64dcda36f612180pquerna<directivesynopsis>
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive<description>Maps a URL to a filesystem location and designates the
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivetarget as a CGI script</description>
103a93c625bcde1a6a7a5155b64dcda36f612180pquerna<var>file-path</var>|<var>directory-path</var></syntax>
103a93c625bcde1a6a7a5155b64dcda36f612180pquerna<contextlist><context>server config</context><context>virtual host</context>
f23fb63b05f89f47d7a3099491f2c68dcce432e9kess</contextlist>
9970ad80054f477c708284a0d030a5bd26e412a9covener <p>The <directive>ScriptAlias</directive> directive has the same
9970ad80054f477c708284a0d030a5bd26e412a9covener behavior as the <directive module="mod_alias">Alias</directive>
9970ad80054f477c708284a0d030a5bd26e412a9covener directive, except that in addition it marks the target directory
9970ad80054f477c708284a0d030a5bd26e412a9covener as containing CGI scripts that will be processed by <module
9970ad80054f477c708284a0d030a5bd26e412a9covener >mod_cgi</module>'s cgi-script handler. URLs with a case-sensitive
9970ad80054f477c708284a0d030a5bd26e412a9covener (%-decoded) path beginning with <var>URL-path</var> will be mapped
9970ad80054f477c708284a0d030a5bd26e412a9covener to scripts beginning with the second argument, which is a full
9970ad80054f477c708284a0d030a5bd26e412a9covener pathname in the local filesystem.</p>
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd <p>A request for <code>http://example.com/cgi-bin/foo</code> would cause the
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd server to run the script <code>/web/cgi-bin/foo</code>. This configuration
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd is essentially equivalent to:</p>
b12b918ae6baf9c5762ed61b7393d0e2198378c0nd <Location /cgi-bin ><br />
da637bcae7b6e150470e701af29da5604a34a17erbowen SetHandler cgi-script<br />
da637bcae7b6e150470e701af29da5604a34a17erbowen Options +ExecCGI<br />
da637bcae7b6e150470e701af29da5604a34a17erbowen </Location>
da637bcae7b6e150470e701af29da5604a34a17erbowen <p><directive>ScriptAlias</directive> can also be used in conjunction with
da637bcae7b6e150470e701af29da5604a34a17erbowen a script or handler you have. For example:</p>
7802d43d20007fa575e43b6ae77d5177ceffdb71sf </example>
86120957a14f91da0a1a103eaf4d7710b1dd9e2asf <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
113961f0559eb026ea0d379cb7350f82bc09d710druggeri handler. You may want to use this as a wrapper for CGI so that you can add
113961f0559eb026ea0d379cb7350f82bc09d710druggeri content, or some other bespoke action.</p>
113961f0559eb026ea0d379cb7350f82bc09d710druggeri <note type="warning">It is safer to avoid placing CGI scripts under the
113961f0559eb026ea0d379cb7350f82bc09d710druggeri <directive module="core">DocumentRoot</directive> in order to
113961f0559eb026ea0d379cb7350f82bc09d710druggeri avoid accidentally revealing their source code if the
113961f0559eb026ea0d379cb7350f82bc09d710druggeri configuration is ever changed. The
113961f0559eb026ea0d379cb7350f82bc09d710druggeri <directive>ScriptAlias</directive> makes this easy by mapping a
113961f0559eb026ea0d379cb7350f82bc09d710druggeri URL and designating CGI scripts at the same time. If you do
113961f0559eb026ea0d379cb7350f82bc09d710druggeri choose to place your CGI scripts in a directory already
113961f0559eb026ea0d379cb7350f82bc09d710druggeri accessible from the web, do not use
113961f0559eb026ea0d379cb7350f82bc09d710druggeri <directive>ScriptAlias</directive>. Instead, use <directive
113961f0559eb026ea0d379cb7350f82bc09d710druggeri module="core" type="section">Directory</directive>, <directive
113961f0559eb026ea0d379cb7350f82bc09d710druggeri module="core">SetHandler</directive>, and <directive
113961f0559eb026ea0d379cb7350f82bc09d710druggeri <Directory /usr/local/apache2/htdocs/cgi-bin ><br />
113961f0559eb026ea0d379cb7350f82bc09d710druggeri SetHandler cgi-script<br />
113961f0559eb026ea0d379cb7350f82bc09d710druggeri Options ExecCGI<br />
113961f0559eb026ea0d379cb7350f82bc09d710druggeri </Directory>
113961f0559eb026ea0d379cb7350f82bc09d710druggeri This is necessary since multiple <var>URL-paths</var> can map
113961f0559eb026ea0d379cb7350f82bc09d710druggeri to the same filesystem location, potentially bypassing the
113961f0559eb026ea0d379cb7350f82bc09d710druggeri <directive>ScriptAlias</directive> and revealing the source code
113961f0559eb026ea0d379cb7350f82bc09d710druggeri of the CGI scripts if they are not restricted by a
113961f0559eb026ea0d379cb7350f82bc09d710druggeri <directive module="core">Directory</directive> section.</note>
113961f0559eb026ea0d379cb7350f82bc09d710druggeri<seealso><a href="/howto/cgi.html">CGI Tutorial</a></seealso>
113961f0559eb026ea0d379cb7350f82bc09d710druggeri</directivesynopsis>
113961f0559eb026ea0d379cb7350f82bc09d710druggeri<directivesynopsis>
113961f0559eb026ea0d379cb7350f82bc09d710druggeri<description>Maps a URL to a filesystem location using a regular expression
113961f0559eb026ea0d379cb7350f82bc09d710druggeriand designates the target as a CGI script</description>
113961f0559eb026ea0d379cb7350f82bc09d710druggeri<var>file-path</var>|<var>directory-path</var></syntax>
113961f0559eb026ea0d379cb7350f82bc09d710druggeri<contextlist><context>server config</context><context>virtual host</context>
113961f0559eb026ea0d379cb7350f82bc09d710druggeri</contextlist>
113961f0559eb026ea0d379cb7350f82bc09d710druggeri <p>This directive is equivalent to <directive module="mod_alias"
113961f0559eb026ea0d379cb7350f82bc09d710druggeri >ScriptAlias</directive>, but makes use of
113961f0559eb026ea0d379cb7350f82bc09d710druggeri <glossary ref="regex">regular expressions</glossary>,
113961f0559eb026ea0d379cb7350f82bc09d710druggeri instead of simple prefix matching. The
113961f0559eb026ea0d379cb7350f82bc09d710druggeri supplied regular expression is matched against the URL-path,
113961f0559eb026ea0d379cb7350f82bc09d710druggeri and if it matches, the server will substitute any parenthesized
113961f0559eb026ea0d379cb7350f82bc09d710druggeri matches into the given string and use it as a filename. For
113961f0559eb026ea0d379cb7350f82bc09d710druggeri example, to activate the standard <code>/cgi-bin</code>, one
113961f0559eb026ea0d379cb7350f82bc09d710druggeri might use:</p>
113961f0559eb026ea0d379cb7350f82bc09d710druggeri ScriptAliasMatch ^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive <p>As for AliasMatch, the full range of <glossary ref="rexex">regular
54bcd0e21a5c79158afd3b78bf707a493a5fb33crbowen expression</glossary> power is available.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive For example, it is possible to construct an alias with case-insensitive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive matching of the url-path:</p>
fb77c505254b6e9c925e23e734463e87574f8f40kess ScriptAliasMatch (?i)^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes <p>The considerations related to the difference between
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes <directive module="mod_alias">Alias</directive> and
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes <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>.
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen See <directive module="mod_alias">AliasMatch</directive> for
fb77c505254b6e9c925e23e734463e87574f8f40kess details.</p>
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess</directivesynopsis>
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes</modulesynopsis>