mod_rewrite.xml revision 5d01f40ffd657dd2ac567aacd93cabd162ddfa79
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<?xml version="1.0"?>
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj<!DOCTYPE modulesynopsis SYSTEM "/style/modulesynopsis.dtd">
e942c741056732f50da2074b36fe59805d370650slive<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
5f5d1b4cc970b7f06ff8ef6526128e9a27303d88nd<!-- $LastChangedRevision$ -->
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd<!--
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding Licensed to the Apache Software Foundation (ASF) under one or more
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding contributor license agreements. See the NOTICE file distributed with
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding this work for additional information regarding copyright ownership.
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding The ASF licenses this file to You under the Apache License, Version 2.0
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding (the "License"); you may not use this file except in compliance with
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding the License. You may obtain a copy of the License at
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd http://www.apache.org/licenses/LICENSE-2.0
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd Unless required by applicable law or agreed to in writing, software
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd distributed under the License is distributed on an "AS IS" BASIS,
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd See the License for the specific language governing permissions and
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd limitations under the License.
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd-->
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd
7db9f691a00ead175b03335457ca296a33ddf31bnd<modulesynopsis metafile="mod_rewrite.xml.meta">
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
5f18f92c1354462df6dc2ba38277a953fa700b13gryzor<name>mod_rewrite</name>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<description>Provides a rule-based rewriting engine to rewrite requested
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfsliveURLs on the fly</description>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<status>Extension</status>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<sourcefile>mod_rewrite.c</sourcefile>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<identifier>rewrite_module</identifier>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<summary>
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim <p>The <module>mod_rewrite</module> module uses a rule-based rewriting
eda63965b78ffeb9384c429c53f4eb5d22c2ca2arbowen engine, based on a PCRE regular-expression parser, to rewrite requested URLs on
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim the fly. By default, <module>mod_rewrite</module> maps a URL to a filesystem
f6445f3ad1c82f9398dc8edd77093cd3e20b806cnoirin path. However, it can also be used to redirect one URL to another URL, or
f6445f3ad1c82f9398dc8edd77093cd3e20b806cnoirin to invoke an internal proxy fetch.</p>
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim <p><module>mod_rewrite</module> provides a flexible and powerful way to
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim manipulate URLs using an unlimited number of rules. Each rule can have an
f6445f3ad1c82f9398dc8edd77093cd3e20b806cnoirin unlimited number of attached rule conditions, to allow you to rewrite URL
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim based on server variables, environment variables, HTTP headers, or time
f6445f3ad1c82f9398dc8edd77093cd3e20b806cnoirin stamps.</p>
f6445f3ad1c82f9398dc8edd77093cd3e20b806cnoirin <p><module>mod_rewrite</module> operates on the full URL path, including the
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim path-info section. A rewrite rule can be invoked in
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim <code>httpd.conf</code> or in <code>.htaccess</code>. The path generated
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim by a rewrite rule can include a query string, or can lead to internal
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim sub-processing, external request redirection, or internal proxy
f6445f3ad1c82f9398dc8edd77093cd3e20b806cnoirin throughput.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen <p>Further details, discussion, and examples, are provided in the
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen <a href="/rewrite/">detailed mod_rewrite documentation</a>.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</summary>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
7571ea383299910bead3e93e66246cb212a28d0figalic<section id="logging"><title>Logging</title>
bc36e90829b1ee123307a2339519265139a88173sf
bc36e90829b1ee123307a2339519265139a88173sf <p><module>mod_rewrite</module> offers detailed logging of its actions
bc36e90829b1ee123307a2339519265139a88173sf at the <code>trace1</code> to <code>trace8</code> log levels. The
bc36e90829b1ee123307a2339519265139a88173sf log level can be set specifically for <module>mod_rewrite</module>
bc36e90829b1ee123307a2339519265139a88173sf using the <directive module="core">LogLevel</directive> directive: Up to
bc36e90829b1ee123307a2339519265139a88173sf level <code>debug</code>, no actions are logged, while <code>trace8</code>
bc36e90829b1ee123307a2339519265139a88173sf means that practically all actions are logged.</p>
bc36e90829b1ee123307a2339519265139a88173sf
bc36e90829b1ee123307a2339519265139a88173sf <note>
bc36e90829b1ee123307a2339519265139a88173sf Using a high trace log level for <module>mod_rewrite</module>
bc36e90829b1ee123307a2339519265139a88173sf will slow down your Apache HTTP Server dramatically! Use a log
1f0a28764a0520e43ce3a9130e56236fd67cd568igalic level higher than <code>trace2</code> only for debugging!
bc36e90829b1ee123307a2339519265139a88173sf </note>
bc36e90829b1ee123307a2339519265139a88173sf
bc36e90829b1ee123307a2339519265139a88173sf <example><title>Example</title>
3a257106808eabaefbb483bdc6273e7af062ead8humbedooh <highlight language="config">
4927aa0c58523071e62d47580cec3b1fb1100ae2rbowen LogLevel alert rewrite:trace3
3a257106808eabaefbb483bdc6273e7af062ead8humbedooh </highlight>
bc36e90829b1ee123307a2339519265139a88173sf </example>
bc36e90829b1ee123307a2339519265139a88173sf
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen <note><title>RewriteLog</title>
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen <p>Those familiar with earlier versions of
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen <module>mod_rewrite</module> will no doubt be looking for the
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen <code>RewriteLog</code> and <code>RewriteLogLevel</code>
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen directives. This functionality has been completely replaced by the
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen new per-module logging configuration mentioned above.
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen </p>
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen <p>To get just the <module>mod_rewrite</module>-specific log
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen messages, pipe the log file through grep:</p>
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen <example>
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen tail -f error_log|fgrep '[rewrite:'
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen </example>
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen </note>
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen
bc36e90829b1ee123307a2339519265139a88173sf</section>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<directivesynopsis>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<name>RewriteEngine</name>
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj<description>Enables or disables runtime rewriting engine</description>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<syntax>RewriteEngine on|off</syntax>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<default>RewriteEngine off</default>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<contextlist><context>server config</context><context>virtual host</context>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<context>directory</context><context>.htaccess</context></contextlist>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<override>FileInfo</override>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
5f18f92c1354462df6dc2ba38277a953fa700b13gryzor<usage>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>The <directive>RewriteEngine</directive> directive enables or
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive disables the runtime rewriting engine. If it is set to
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>off</code> this module does no runtime processing at
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive all. It does not even update the <code>SCRIPT_URx</code>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive environment variables.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
b81ce796b0cf3ce2d4aec801645948f3de0f6390jailletc <p>Use this directive to disable rules in a particular context,
add05d0fdfd18b515383629b1b58130ada068dffrbowen rather than commenting out all the <directive
add05d0fdfd18b515383629b1b58130ada068dffrbowen module="mod_rewrite">RewriteRule</directive> directives.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
4c36c711036219c80d5517d35be68a4769c15291slive <p>Note that rewrite configurations are not
4c36c711036219c80d5517d35be68a4769c15291slive inherited by virtual hosts. This means that you need to have a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>RewriteEngine on</code> directive for each virtual host
4c36c711036219c80d5517d35be68a4769c15291slive in which you wish to use rewrite rules.</p>
fc9f416faa11879811f17d6efadedbf81cfd52a1covener
fc9f416faa11879811f17d6efadedbf81cfd52a1covener <p><directive>RewriteMap</directive> directives of the type <code>prg</code>
fc9f416faa11879811f17d6efadedbf81cfd52a1covener are not started during server initialization if they're defined in a
fc9f416faa11879811f17d6efadedbf81cfd52a1covener context that does not have <directive>RewriteEngine</directive> set to
fc9f416faa11879811f17d6efadedbf81cfd52a1covener <code>on</code></p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</usage>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</directivesynopsis>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<directivesynopsis>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<name>RewriteOptions</name>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<description>Sets some special options for the rewrite engine</description>
9ed9ba1fcf0a4a39f78f5f809c661bbd590b70eand<syntax>RewriteOptions <var>Options</var></syntax>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<contextlist><context>server config</context><context>virtual host</context>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<context>directory</context><context>.htaccess</context></contextlist>
630c456b6461158be6cc5c5483735e27b13b4ad5nd<override>FileInfo</override>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<usage>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>The <directive>RewriteOptions</directive> directive sets some
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive special options for the current per-server or per-directory
5f18f92c1354462df6dc2ba38277a953fa700b13gryzor configuration. The <em>Option</em> string can currently
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin only be one of the following:</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
9ed9ba1fcf0a4a39f78f5f809c661bbd590b70eand <dl>
6f2fbf354b34981f398cf0313aa44702ea2a7066covener <dt><code>Inherit</code></dt>
1437d609a6e92c3f32dfdb0d63fce4fd2243fa0frbowen <dd>
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim
1437d609a6e92c3f32dfdb0d63fce4fd2243fa0frbowen <p>This forces the current configuration to inherit the
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin configuration of the parent. In per-virtual-server context,
9ed9ba1fcf0a4a39f78f5f809c661bbd590b70eand this means that the maps, conditions and rules of the main
9ed9ba1fcf0a4a39f78f5f809c661bbd590b70eand server are inherited. In per-directory context this means
9ed9ba1fcf0a4a39f78f5f809c661bbd590b70eand that conditions and rules of the parent directory's
a4d04b8c74044c58bd4182028a1408d936c95951covener <code>.htaccess</code> configuration or
a4d04b8c74044c58bd4182028a1408d936c95951covener <directive type="section" module="core">Directory</directive>
a4d04b8c74044c58bd4182028a1408d936c95951covener sections are inherited. The inherited rules are virtually copied
a4d04b8c74044c58bd4182028a1408d936c95951covener to the section where this directive is being used. If used in
a4d04b8c74044c58bd4182028a1408d936c95951covener combination with local rules, the inherited rules are copied behind
a4d04b8c74044c58bd4182028a1408d936c95951covener the local rules. The position of this directive - below or above
a4d04b8c74044c58bd4182028a1408d936c95951covener of local rules - has no influence on this behavior. If local
a4d04b8c74044c58bd4182028a1408d936c95951covener rules forced the rewriting to stop, the inherited rules won't
1437d609a6e92c3f32dfdb0d63fce4fd2243fa0frbowen be processed.</p>
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim
1437d609a6e92c3f32dfdb0d63fce4fd2243fa0frbowen <note type="warning">
1437d609a6e92c3f32dfdb0d63fce4fd2243fa0frbowen Rules inherited from the parent scope are applied
1437d609a6e92c3f32dfdb0d63fce4fd2243fa0frbowen <strong>after</strong> rules specified in the child scope.
1437d609a6e92c3f32dfdb0d63fce4fd2243fa0frbowen </note>
1437d609a6e92c3f32dfdb0d63fce4fd2243fa0frbowen </dd>
6f2fbf354b34981f398cf0313aa44702ea2a7066covener
6f2fbf354b34981f398cf0313aa44702ea2a7066covener <dt><code>InheritBefore</code></dt>
6f2fbf354b34981f398cf0313aa44702ea2a7066covener <dd>
6f2fbf354b34981f398cf0313aa44702ea2a7066covener <p> Like <code>Inherit</code> above, but the rules from the parent scope
a20eeb445d781a18f2c86428ccd4bd3a3db1a197jailletc are applied <strong>before</strong> rules specified in the child scope.<br />
6f2fbf354b34981f398cf0313aa44702ea2a7066covener Available in Apache HTTP Server 2.3.10 and later.</p>
6f2fbf354b34981f398cf0313aa44702ea2a7066covener </dd>
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim
37ce4da04e34abd4f13d6842902dec7db0a65fddcovener <dt><code>InheritDown</code></dt>
37ce4da04e34abd4f13d6842902dec7db0a65fddcovener <dd>
37ce4da04e34abd4f13d6842902dec7db0a65fddcovener
37ce4da04e34abd4f13d6842902dec7db0a65fddcovener <p>If this option is enabled, all child configurations will inherit
37ce4da04e34abd4f13d6842902dec7db0a65fddcovener the configuration of the current configuration. It is equivalent to
37ce4da04e34abd4f13d6842902dec7db0a65fddcovener specifying <code>RewriteOptions Inherit</code> in all child
37ce4da04e34abd4f13d6842902dec7db0a65fddcovener configurations. See the <code>Inherit</code> option for more details
a20eeb445d781a18f2c86428ccd4bd3a3db1a197jailletc on how the parent-child relationships are handled.<br />
a20eeb445d781a18f2c86428ccd4bd3a3db1a197jailletc Available in Apache HTTP Server 2.4.8 and later.</p>
37ce4da04e34abd4f13d6842902dec7db0a65fddcovener </dd>
37ce4da04e34abd4f13d6842902dec7db0a65fddcovener
37ce4da04e34abd4f13d6842902dec7db0a65fddcovener <dt><code>InheritDownBefore</code></dt>
37ce4da04e34abd4f13d6842902dec7db0a65fddcovener <dd>
37ce4da04e34abd4f13d6842902dec7db0a65fddcovener
37ce4da04e34abd4f13d6842902dec7db0a65fddcovener <p>Like <code>InheritDown</code> above, but the rules from the current
37ce4da04e34abd4f13d6842902dec7db0a65fddcovener scope are applied <strong>before</strong> rules specified in any child's
a20eeb445d781a18f2c86428ccd4bd3a3db1a197jailletc scope.<br />
a20eeb445d781a18f2c86428ccd4bd3a3db1a197jailletc Available in Apache HTTP Server 2.4.8 and later.</p>
37ce4da04e34abd4f13d6842902dec7db0a65fddcovener </dd>
37ce4da04e34abd4f13d6842902dec7db0a65fddcovener
37ce4da04e34abd4f13d6842902dec7db0a65fddcovener <dt><code>IgnoreInherit</code></dt>
37ce4da04e34abd4f13d6842902dec7db0a65fddcovener <dd>
37ce4da04e34abd4f13d6842902dec7db0a65fddcovener
37ce4da04e34abd4f13d6842902dec7db0a65fddcovener <p>This option forces the current and child configurations to ignore
37ce4da04e34abd4f13d6842902dec7db0a65fddcovener all rules that would be inherited from a parent specifying
a20eeb445d781a18f2c86428ccd4bd3a3db1a197jailletc <code>InheritDown</code> or <code>InheritDownBefore</code>.<br />
a20eeb445d781a18f2c86428ccd4bd3a3db1a197jailletc Available in Apache HTTP Server 2.4.8 and later.</p>
37ce4da04e34abd4f13d6842902dec7db0a65fddcovener </dd>
37ce4da04e34abd4f13d6842902dec7db0a65fddcovener
46578aac029a8de1703b48f8050c56d3e9442e5eminfrin <dt><code>AllowNoSlash</code></dt>
46578aac029a8de1703b48f8050c56d3e9442e5eminfrin <dd>
46578aac029a8de1703b48f8050c56d3e9442e5eminfrin <p>By default, <module>mod_rewrite</module> will ignore URLs that map to a
46578aac029a8de1703b48f8050c56d3e9442e5eminfrin directory on disk but lack a trailing slash, in the expectation that
46578aac029a8de1703b48f8050c56d3e9442e5eminfrin the <module>mod_dir</module> module will issue the client with a redirect to
46578aac029a8de1703b48f8050c56d3e9442e5eminfrin the canonical URL with a trailing slash.</p>
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coar
46578aac029a8de1703b48f8050c56d3e9442e5eminfrin <p>When the <directive module="mod_dir">DirectorySlash</directive> directive
46578aac029a8de1703b48f8050c56d3e9442e5eminfrin is set to off, the <code>AllowNoSlash</code> option can be enabled to ensure
46578aac029a8de1703b48f8050c56d3e9442e5eminfrin that rewrite rules are no longer ignored. This option makes it possible to
46578aac029a8de1703b48f8050c56d3e9442e5eminfrin apply rewrite rules within .htaccess files that match the directory without
a20eeb445d781a18f2c86428ccd4bd3a3db1a197jailletc a trailing slash, if so desired.<br />
a20eeb445d781a18f2c86428ccd4bd3a3db1a197jailletc Available in Apache HTTP Server 2.4.0 and later.</p>
46578aac029a8de1703b48f8050c56d3e9442e5eminfrin </dd>
46578aac029a8de1703b48f8050c56d3e9442e5eminfrin
72709d60c290ddc1f60fe2c78ab67b7954e9230djorton <dt><code>AllowAnyURI</code></dt>
72709d60c290ddc1f60fe2c78ab67b7954e9230djorton <dd>
72709d60c290ddc1f60fe2c78ab67b7954e9230djorton
72709d60c290ddc1f60fe2c78ab67b7954e9230djorton <p>When <directive module="mod_rewrite">RewriteRule</directive>
72709d60c290ddc1f60fe2c78ab67b7954e9230djorton is used in <code>VirtualHost</code> or server context with
72709d60c290ddc1f60fe2c78ab67b7954e9230djorton version 2.2.22 or later of httpd, <module>mod_rewrite</module>
72709d60c290ddc1f60fe2c78ab67b7954e9230djorton will only process the rewrite rules if the request URI is a <a
ae382386f18506586972cdd63c09bb27a1685062nd href="directive-dict.html#Syntax">URL-path</a>. This avoids
72709d60c290ddc1f60fe2c78ab67b7954e9230djorton some security issues where particular rules could allow
72709d60c290ddc1f60fe2c78ab67b7954e9230djorton "surprising" pattern expansions (see <a
72709d60c290ddc1f60fe2c78ab67b7954e9230djorton href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-3368">CVE-2011-3368</a>
72709d60c290ddc1f60fe2c78ab67b7954e9230djorton and <a
72709d60c290ddc1f60fe2c78ab67b7954e9230djorton href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-4317">CVE-2011-4317</a>).
72709d60c290ddc1f60fe2c78ab67b7954e9230djorton To lift the restriction on matching a URL-path, the
72709d60c290ddc1f60fe2c78ab67b7954e9230djorton <code>AllowAnyURI</code> option can be enabled, and
72709d60c290ddc1f60fe2c78ab67b7954e9230djorton <module>mod_rewrite</module> will apply the rule set to any
72709d60c290ddc1f60fe2c78ab67b7954e9230djorton request URI string, regardless of whether that string matches
a20eeb445d781a18f2c86428ccd4bd3a3db1a197jailletc the URL-path grammar required by the HTTP specification.<br />
a20eeb445d781a18f2c86428ccd4bd3a3db1a197jailletc Available in Apache HTTP Server 2.4.3 and later.</p>
72709d60c290ddc1f60fe2c78ab67b7954e9230djorton
72709d60c290ddc1f60fe2c78ab67b7954e9230djorton <note type="warning">
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coar <title>Security Warning</title>
72709d60c290ddc1f60fe2c78ab67b7954e9230djorton
72709d60c290ddc1f60fe2c78ab67b7954e9230djorton <p>Enabling this option will make the server vulnerable to
72709d60c290ddc1f60fe2c78ab67b7954e9230djorton security issues if used with rewrite rules which are not
72709d60c290ddc1f60fe2c78ab67b7954e9230djorton carefully authored. It is <strong>strongly recommended</strong>
72709d60c290ddc1f60fe2c78ab67b7954e9230djorton that this option is not used. In particular, beware of input
72709d60c290ddc1f60fe2c78ab67b7954e9230djorton strings containing the '<code>@</code>' character which could
72709d60c290ddc1f60fe2c78ab67b7954e9230djorton change the interpretation of the transformed URI, as per the
72709d60c290ddc1f60fe2c78ab67b7954e9230djorton above CVE names.</p>
72709d60c290ddc1f60fe2c78ab67b7954e9230djorton </note>
72709d60c290ddc1f60fe2c78ab67b7954e9230djorton </dd>
72709d60c290ddc1f60fe2c78ab67b7954e9230djorton
855d6aa9f641cd160ee4265824a3ad3d06231c76covener <dt><code>MergeBase</code></dt>
855d6aa9f641cd160ee4265824a3ad3d06231c76covener <dd>
855d6aa9f641cd160ee4265824a3ad3d06231c76covener
855d6aa9f641cd160ee4265824a3ad3d06231c76covener <p>With this option, the value of <directive module="mod_rewrite"
855d6aa9f641cd160ee4265824a3ad3d06231c76covener >RewriteBase</directive> is copied from where it's explicitly defined
855d6aa9f641cd160ee4265824a3ad3d06231c76covener into any sub-directory or sub-location that doesn't define its own
0c907a556984e194d57caeac4eb5e36c2387f5d7jailletc <directive module="mod_rewrite">RewriteBase</directive>. This was the
0c907a556984e194d57caeac4eb5e36c2387f5d7jailletc default behavior in 2.4.0 through 2.4.3, and the flag to restore it is
0c907a556984e194d57caeac4eb5e36c2387f5d7jailletc available Apache HTTP Server 2.4.4 and later.</p>
855d6aa9f641cd160ee4265824a3ad3d06231c76covener </dd>
6f2fbf354b34981f398cf0313aa44702ea2a7066covener
06bb3e11d3e997937534ae7bd45b3631d3b5e5bacovener <dt><code>IgnoreContextInfo</code></dt>
06bb3e11d3e997937534ae7bd45b3631d3b5e5bacovener <dd>
06bb3e11d3e997937534ae7bd45b3631d3b5e5bacovener
24749088ef0f0708792f36e79b50ea0e40cfca6ccovener <p>When a relative substitution is made
06bb3e11d3e997937534ae7bd45b3631d3b5e5bacovener in directory (htaccess) context and <directive module="mod_rewrite"
06bb3e11d3e997937534ae7bd45b3631d3b5e5bacovener >RewriteBase</directive> has not been set, this module uses some
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coar extended URL and filesystem context information to change the
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coar relative substitution back into a URL. Modules such as
06bb3e11d3e997937534ae7bd45b3631d3b5e5bacovener <module>mod_userdir</module> and <module>mod_alias</module>
13fc29a22b0eb71377b3ebebc2419cb664c9fd0ecovener supply this extended context info. </p>
06bb3e11d3e997937534ae7bd45b3631d3b5e5bacovener </dd>
06bb3e11d3e997937534ae7bd45b3631d3b5e5bacovener
06bb3e11d3e997937534ae7bd45b3631d3b5e5bacovener </dl>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</usage>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</directivesynopsis>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<directivesynopsis>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<name>RewriteMap</name>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<description>Defines a mapping function for key-lookup</description>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<syntax>RewriteMap <em>MapName</em> <em>MapType</em>:<em>MapSource</em>
39dc0634642fcb347ac41afe62690d2493dc5588jkaluza <em>MapTypeOptions</em>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</syntax>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<contextlist><context>server config</context><context>virtual host</context>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</contextlist>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<usage>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>The <directive>RewriteMap</directive> directive defines a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em>Rewriting Map</em> which can be used inside rule
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive substitution strings by the mapping-functions to
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive insert/substitute fields through a key lookup. The source of
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive this lookup can be of various types.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>The <a id="mapfunc" name="mapfunc"><em>MapName</em></a> is
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the name of the map and will be used to specify a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive mapping-function for the substitution strings of a rewriting
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive rule via one of the following constructs:</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele <p class="indent">
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <strong><code>${</code> <em>MapName</em> <code>:</code>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em>LookupKey</em> <code>}</code><br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>${</code> <em>MapName</em> <code>:</code>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em>LookupKey</em> <code>|</code> <em>DefaultValue</em>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>}</code></strong>
97a9a944b5887e91042b019776c41d5dd74557aferikabele </p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin <p>When such a construct occurs, the map <em>MapName</em> is
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive consulted and the key <em>LookupKey</em> is looked-up. If the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive key is found, the map-function construct is substituted by
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em>SubstValue</em>. If the key is not found then it is
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive substituted by <em>DefaultValue</em> or by the empty string
7992de7f9e82ab86effe3dcc5279fb959f6c398dcovener if no <em>DefaultValue</em> was specified. Empty values
7992de7f9e82ab86effe3dcc5279fb959f6c398dcovener behave as if the key was absent, therefore it is not possible
7992de7f9e82ab86effe3dcc5279fb959f6c398dcovener to distinguish between empty-valued keys and absent keys.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
ee73c32ad65734a6514bcbd0ed6e20494e8a50bdrbowen <p>For example, you might define a
ee73c32ad65734a6514bcbd0ed6e20494e8a50bdrbowen <directive>RewriteMap</directive> as:</p>
ee73c32ad65734a6514bcbd0ed6e20494e8a50bdrbowen
3a257106808eabaefbb483bdc6273e7af062ead8humbedooh <highlight language="config">
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coarRewriteMap examplemap "txt:/path/to/file/map.txt"
3a257106808eabaefbb483bdc6273e7af062ead8humbedooh </highlight>
ee73c32ad65734a6514bcbd0ed6e20494e8a50bdrbowen
ee73c32ad65734a6514bcbd0ed6e20494e8a50bdrbowen <p>You would then be able to use this map in a
ee73c32ad65734a6514bcbd0ed6e20494e8a50bdrbowen <directive>RewriteRule</directive> as follows:</p>
ee73c32ad65734a6514bcbd0ed6e20494e8a50bdrbowen
3a257106808eabaefbb483bdc6273e7af062ead8humbedooh <highlight language="config">
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coarRewriteRule "^/ex/(.*)" "${examplemap:$1}"
3a257106808eabaefbb483bdc6273e7af062ead8humbedooh </highlight>
ee73c32ad65734a6514bcbd0ed6e20494e8a50bdrbowen
39dc0634642fcb347ac41afe62690d2493dc5588jkaluza <p>The meaning of the <em>MapTypeOptions</em> argument depends on
39dc0634642fcb347ac41afe62690d2493dc5588jkaluza particular <em>MapType</em>. See the
39dc0634642fcb347ac41afe62690d2493dc5588jkaluza <a href="/rewrite/rewritemap.html">Using RewriteMap</a> for
39dc0634642fcb347ac41afe62690d2493dc5588jkaluza more information.</p>
39dc0634642fcb347ac41afe62690d2493dc5588jkaluza
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>The following combinations for <em>MapType</em> and
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em>MapSource</em> can be used:</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
790a477f6ce41161c4173c1e5080a1f569976a1erbowen <dl>
790a477f6ce41161c4173c1e5080a1f569976a1erbowen
790a477f6ce41161c4173c1e5080a1f569976a1erbowen <dt>txt</dt>
790a477f6ce41161c4173c1e5080a1f569976a1erbowen <dd>A plain text file containing space-separated key-value
790a477f6ce41161c4173c1e5080a1f569976a1erbowen pairs, one per line. (<a href="/rewrite/rewritemap.html#txt">Details ...</a>)</dd>
790a477f6ce41161c4173c1e5080a1f569976a1erbowen
790a477f6ce41161c4173c1e5080a1f569976a1erbowen <dt>rnd</dt>
790a477f6ce41161c4173c1e5080a1f569976a1erbowen <dd>Randomly selects an entry from a plain text file (<a href="/rewrite/rewritemap.html#rnd">Details ...</a>)</dd>
790a477f6ce41161c4173c1e5080a1f569976a1erbowen
790a477f6ce41161c4173c1e5080a1f569976a1erbowen <dt>dbm</dt>
790a477f6ce41161c4173c1e5080a1f569976a1erbowen <dd>Looks up an entry in a dbm file containing name, value
0a3142725875ea286597e083547d34d98f8c1f2drbowen pairs. Hash is constructed from a plain text file format using
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim the <code><a href="/programs/httxt2dbm.html">httxt2dbm</a></code>
790a477f6ce41161c4173c1e5080a1f569976a1erbowen utility. (<a href="/rewrite/rewritemap.html#dbm">Details ...</a>)</dd>
0a3142725875ea286597e083547d34d98f8c1f2drbowen
790a477f6ce41161c4173c1e5080a1f569976a1erbowen <dt>int</dt>
dc585e0df783dd91b8121ea1cfa743cea2ac12fdcovener <dd>One of the four available internal functions provided by
dc585e0df783dd91b8121ea1cfa743cea2ac12fdcovener <code>RewriteMap</code>: toupper, tolower, escape or
dc585e0df783dd91b8121ea1cfa743cea2ac12fdcovener unescape. (<a href="/rewrite/rewritemap.html#int">Details ...</a>)</dd>
790a477f6ce41161c4173c1e5080a1f569976a1erbowen
790a477f6ce41161c4173c1e5080a1f569976a1erbowen <dt>prg</dt>
790a477f6ce41161c4173c1e5080a1f569976a1erbowen <dd>Calls an external program or script to process the
790a477f6ce41161c4173c1e5080a1f569976a1erbowen rewriting. (<a href="/rewrite/rewritemap.html#prg">Details ...</a>)</dd>
790a477f6ce41161c4173c1e5080a1f569976a1erbowen
790a477f6ce41161c4173c1e5080a1f569976a1erbowen <dt>dbd or fastdbd</dt>
790a477f6ce41161c4173c1e5080a1f569976a1erbowen <dd>A SQL SELECT statement to be performed to look up the
790a477f6ce41161c4173c1e5080a1f569976a1erbowen rewrite target. (<a href="/rewrite/rewritemap.html#dbd">Details ...</a>)</dd>
790a477f6ce41161c4173c1e5080a1f569976a1erbowen </dl>
0a3142725875ea286597e083547d34d98f8c1f2drbowen
0a3142725875ea286597e083547d34d98f8c1f2drbowen <p>Further details, and numerous examples, may be found in the <a
0a3142725875ea286597e083547d34d98f8c1f2drbowen href="/rewrite/rewritemap.html">RewriteMap HowTo</a></p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</usage>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</directivesynopsis>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<directivesynopsis>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<name>RewriteBase</name>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<description>Sets the base URL for per-directory rewrites</description>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<syntax>RewriteBase <em>URL-path</em></syntax>
635de20c16ef862bfc5b0d5f9ceb40ebeaddfdf3noirin<default>None</default>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<contextlist><context>directory</context><context>.htaccess</context>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</contextlist>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<override>FileInfo</override>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<usage>
825119afb439c424c7c124efc0d6d6b197a1f356covener <p>The <directive>RewriteBase</directive> directive specifies the
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coar URL prefix to be used for per-directory (htaccess)
825119afb439c424c7c124efc0d6d6b197a1f356covener <directive>RewriteRule</directive> directives that substitute a relative
825119afb439c424c7c124efc0d6d6b197a1f356covener path.</p>
825119afb439c424c7c124efc0d6d6b197a1f356covener <p> This directive is <em>required</em> when you use a relative path
825119afb439c424c7c124efc0d6d6b197a1f356covener in a substitution in per-directory (htaccess) context unless either
8a742f67b2f07505fc32e4f48f436509ea8f0320nilgun of the following conditions are true:</p>
825119afb439c424c7c124efc0d6d6b197a1f356covener <ul>
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coar <li> The original request, and the substitution, are underneath the
825119afb439c424c7c124efc0d6d6b197a1f356covener <directive module="core">DocumentRoot</directive>
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coar (as opposed to reachable by other means, such as
825119afb439c424c7c124efc0d6d6b197a1f356covener <directive module="mod_alias">Alias</directive>).</li>
825119afb439c424c7c124efc0d6d6b197a1f356covener <li> The <em>filesystem</em> path to the directory containing the
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coar <directive>RewriteRule</directive>, suffixed by the relative
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coar substitution is also valid as a URL path on the server
825119afb439c424c7c124efc0d6d6b197a1f356covener (this is rare).</li>
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coar <li> In Apache HTTP Server 2.4.11 and later, this directive may be
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coar omitted when the request is mapped via
06bb3e11d3e997937534ae7bd45b3631d3b5e5bacovener <directive module="mod_alias">Alias</directive>
06bb3e11d3e997937534ae7bd45b3631d3b5e5bacovener or <module>mod_userdir</module>.</li>
825119afb439c424c7c124efc0d6d6b197a1f356covener </ul>
825119afb439c424c7c124efc0d6d6b197a1f356covener
825119afb439c424c7c124efc0d6d6b197a1f356covener<p> In the example below, <directive>RewriteBase</directive> is necessary
825119afb439c424c7c124efc0d6d6b197a1f356covener to avoid rewriting to http://example.com/opt/myapp-1.2.3/welcome.html
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coar since the resource was not relative to the document root. This
825119afb439c424c7c124efc0d6d6b197a1f356covener misconfiguration would normally cause the server to look for an "opt"
825119afb439c424c7c124efc0d6d6b197a1f356covener directory under the document root.</p>
3a257106808eabaefbb483bdc6273e7af062ead8humbedooh<highlight language="config">
c3c937a1510d6ff9cfa28ef3713e787f0e1a39c9coarDocumentRoot "/var/www/example.com"
b475917ddf898282aa51ce31b3275c2c4783ce98coarAliasMatch "^/myapp" "/opt/myapp-1.2.3"
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar&lt;Directory "/opt/myapp-1.2.3"&gt;
3a257106808eabaefbb483bdc6273e7af062ead8humbedooh RewriteEngine On
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coar RewriteBase "/myapp/"
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coar RewriteRule "^index\.html$" "welcome.html"
825119afb439c424c7c124efc0d6d6b197a1f356covener&lt;/Directory&gt;
3a257106808eabaefbb483bdc6273e7af062ead8humbedooh</highlight>
06bb3e11d3e997937534ae7bd45b3631d3b5e5bacovener
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</usage>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</directivesynopsis>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<directivesynopsis>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<name>RewriteCond</name>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<description>Defines a condition under which rewriting will take place
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</description>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<syntax> RewriteCond
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em>TestString</em> <em>CondPattern</em></syntax>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<contextlist><context>server config</context><context>virtual host</context>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<context>directory</context><context>.htaccess</context></contextlist>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<override>FileInfo</override>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<usage>
fa0f379e3845907d7c1087d885169e302239bdbbnd <p>The <directive>RewriteCond</directive> directive defines a
fa0f379e3845907d7c1087d885169e302239bdbbnd rule condition. One or more <directive>RewriteCond</directive>
fa0f379e3845907d7c1087d885169e302239bdbbnd can precede a <directive module="mod_rewrite">RewriteRule</directive>
fa0f379e3845907d7c1087d885169e302239bdbbnd directive. The following rule is then only used if both
fa0f379e3845907d7c1087d885169e302239bdbbnd the current state of the URI matches its pattern, <strong
fa0f379e3845907d7c1087d885169e302239bdbbnd >and</strong> if these conditions are met.</p>
fa0f379e3845907d7c1087d885169e302239bdbbnd
fa0f379e3845907d7c1087d885169e302239bdbbnd <p><em>TestString</em> is a string which can contain the
fa0f379e3845907d7c1087d885169e302239bdbbnd following expanded constructs in addition to plain text:</p>
fa0f379e3845907d7c1087d885169e302239bdbbnd
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <ul>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <strong>RewriteRule backreferences</strong>: These are
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin backreferences of the form <strong><code>$N</code></strong>
b115299831a7b4bbec58a88d708d8536e1ecd50csf (0 &lt;= N &lt;= 9). $1 to $9 provide access to the grouped
fa0f379e3845907d7c1087d885169e302239bdbbnd parts (in parentheses) of the pattern, from the
fa0f379e3845907d7c1087d885169e302239bdbbnd <code>RewriteRule</code> which is subject to the current
b115299831a7b4bbec58a88d708d8536e1ecd50csf set of <code>RewriteCond</code> conditions. $0 provides
b115299831a7b4bbec58a88d708d8536e1ecd50csf access to the whole string matched by that pattern.
fa0f379e3845907d7c1087d885169e302239bdbbnd </li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <strong>RewriteCond backreferences</strong>: These are
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin backreferences of the form <strong><code>%N</code></strong>
b115299831a7b4bbec58a88d708d8536e1ecd50csf (0 &lt;= N &lt;= 9). %1 to %9 provide access to the grouped
fa0f379e3845907d7c1087d885169e302239bdbbnd parts (again, in parentheses) of the pattern, from the last matched
fa0f379e3845907d7c1087d885169e302239bdbbnd <code>RewriteCond</code> in the current set
b115299831a7b4bbec58a88d708d8536e1ecd50csf of conditions. %0 provides access to the whole string matched by
b115299831a7b4bbec58a88d708d8536e1ecd50csf that pattern.
fa0f379e3845907d7c1087d885169e302239bdbbnd </li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <strong>RewriteMap expansions</strong>: These are
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin expansions of the form <strong><code
206b5dce9e48924aa9f12ce87f14856a4cd3fb68takashi >${mapname:key|default}</code></strong>.
fa0f379e3845907d7c1087d885169e302239bdbbnd See <a href="#mapfunc">the documentation for
fa0f379e3845907d7c1087d885169e302239bdbbnd RewriteMap</a> for more details.
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>
fa0f379e3845907d7c1087d885169e302239bdbbnd <strong>Server-Variables</strong>: These are variables of
5f18f92c1354462df6dc2ba38277a953fa700b13gryzor the form
fa0f379e3845907d7c1087d885169e302239bdbbnd <strong><code>%{</code> <em>NAME_OF_VARIABLE</em>
fa0f379e3845907d7c1087d885169e302239bdbbnd <code>}</code></strong>
fa0f379e3845907d7c1087d885169e302239bdbbnd where <em>NAME_OF_VARIABLE</em> can be a string taken
fa0f379e3845907d7c1087d885169e302239bdbbnd from the following list:
fa0f379e3845907d7c1087d885169e302239bdbbnd
fa0f379e3845907d7c1087d885169e302239bdbbnd <table>
1597043cec6ad37fa4154bf09b0fccdabed1a239slive <columnspec><column width=".3"/><column width=".3"/>
1597043cec6ad37fa4154bf09b0fccdabed1a239slive <column width=".3"/></columnspec>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <tr>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <th>HTTP headers:</th> <th>connection &amp; request:</th> <th></th>
206b5dce9e48924aa9f12ce87f14856a4cd3fb68takashi </tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele <tr>
206b5dce9e48924aa9f12ce87f14856a4cd3fb68takashi <td>
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc HTTP_ACCEPT<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive HTTP_COOKIE<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive HTTP_FORWARDED<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive HTTP_HOST<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive HTTP_PROXY_CONNECTION<br />
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc HTTP_REFERER<br />
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc HTTP_USER_AGENT<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj <td>
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc AUTH_TYPE<br />
a4bcadc43f29245972e9e8745a5114610065329ccovener CONN_REMOTE_ADDR<br />
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc CONTEXT_PREFIX<br />
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc CONTEXT_DOCUMENT_ROOT<br />
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc IPV6<br />
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc PATH_INFO<br />
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc QUERY_STRING<br />
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc REMOTE_ADDR<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive REMOTE_HOST<br />
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc REMOTE_IDENT<br />
74a6de79356cd15d2e47065087785e36dd65aa41nd REMOTE_PORT<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive REMOTE_USER<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive REQUEST_METHOD<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive SCRIPT_FILENAME<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </td>
206b5dce9e48924aa9f12ce87f14856a4cd3fb68takashi
206b5dce9e48924aa9f12ce87f14856a4cd3fb68takashi <td></td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <tr>
53d2fd50ff45e7c568f0588c742a5ef9edf8e275rbowen <th>server internals:</th> <th>date and time:</th> <th>specials:</th>
206b5dce9e48924aa9f12ce87f14856a4cd3fb68takashi </tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele <tr>
206b5dce9e48924aa9f12ce87f14856a4cd3fb68takashi <td>
206b5dce9e48924aa9f12ce87f14856a4cd3fb68takashi DOCUMENT_ROOT<br />
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc SCRIPT_GROUP<br />
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc SCRIPT_USER<br />
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc SERVER_ADDR<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive SERVER_ADMIN<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive SERVER_NAME<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive SERVER_PORT<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive SERVER_PROTOCOL<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive SERVER_SOFTWARE<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj <td>
97a9a944b5887e91042b019776c41d5dd74557aferikabele TIME_YEAR<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive TIME_MON<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive TIME_DAY<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive TIME_HOUR<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive TIME_MIN<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive TIME_SEC<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive TIME_WDAY<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive TIME<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj <td>
97a9a944b5887e91042b019776c41d5dd74557aferikabele API_VERSION<br />
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc CONN_REMOTE_ADDR<br />
fb82af0f0cd7b58eef19c54b086131b7e1e1e749madhum HTTPS<br />
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc IS_SUBREQ<br />
9a2b3982c53d51e2d2df29b6f94cc25e2ed134bcjailletc REMOTE_ADDR<br />
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc REQUEST_FILENAME<br />
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc REQUEST_SCHEME<br />
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc REQUEST_URI<br />
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc THE_REQUEST<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </table>
fa0f379e3845907d7c1087d885169e302239bdbbnd
fa0f379e3845907d7c1087d885169e302239bdbbnd <p>These variables all
fa0f379e3845907d7c1087d885169e302239bdbbnd correspond to the similarly named HTTP
cea021a7fc2657b091df4d3b031c4254ec371dd7rbowen MIME-headers, C variables of the Apache HTTP Server or
fa0f379e3845907d7c1087d885169e302239bdbbnd <code>struct tm</code> fields of the Unix system.
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc Most are documented <a href="/expr.html#vars">here</a>
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc or elsewhere in the Manual or in the CGI specification.</p>
6d39241b884dd91f791c438d7846c2acf47d94a8covener
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim <p>SERVER_NAME and SERVER_PORT depend on the values of
6d39241b884dd91f791c438d7846c2acf47d94a8covener <directive module="core">UseCanonicalName</directive> and
6d39241b884dd91f791c438d7846c2acf47d94a8covener <directive module="core">UseCanonicalPhysicalPort</directive>
6d39241b884dd91f791c438d7846c2acf47d94a8covener respectively.</p>
6d39241b884dd91f791c438d7846c2acf47d94a8covener
6d39241b884dd91f791c438d7846c2acf47d94a8covener <p>Those that are special to mod_rewrite include those below.</p>
fa0f379e3845907d7c1087d885169e302239bdbbnd <note>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dl>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dt><code>API_VERSION</code></dt>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
cea021a7fc2657b091df4d3b031c4254ec371dd7rbowen <dd>This is the version of the Apache httpd module API
fa0f379e3845907d7c1087d885169e302239bdbbnd (the internal interface between server and
fa0f379e3845907d7c1087d885169e302239bdbbnd module) in the current httpd build, as defined in
fa0f379e3845907d7c1087d885169e302239bdbbnd include/ap_mmn.h. The module API version
cea021a7fc2657b091df4d3b031c4254ec371dd7rbowen corresponds to the version of Apache httpd in use (in
cea021a7fc2657b091df4d3b031c4254ec371dd7rbowen the release version of Apache httpd 1.3.14, for
fa0f379e3845907d7c1087d885169e302239bdbbnd instance, it is 19990320:10), but is mainly of
fa0f379e3845907d7c1087d885169e302239bdbbnd interest to module authors.</dd>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc <dt><code>CONN_REMOTE_ADDR</code></dt>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc <dd>Since 2.4.8: The peer IP address of the connection (see the
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc <module>mod_remoteip</module> module).</dd>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc <dt><code>HTTPS</code></dt>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc <dd>Will contain the text "on" if the connection is
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc using SSL/TLS, or "off" otherwise. (This variable
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc can be safely used regardless of whether or not
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc <module>mod_ssl</module> is loaded).</dd>
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc <dt><code>IS_SUBREQ</code></dt>
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc <dd>Will contain the text "true" if the request
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc currently being processed is a sub-request,
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc "false" otherwise. Sub-requests may be generated
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc by modules that need to resolve additional files
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc or URIs in order to complete their tasks.</dd>
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc <dt><code>REMOTE_ADDR</code></dt>
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc <dd>The IP address of the remote host (see the
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc <module>mod_remoteip</module> module).</dd>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dt><code>REQUEST_FILENAME</code></dt>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
fa0f379e3845907d7c1087d885169e302239bdbbnd <dd>The full local filesystem path to the file or
c0a201f9f0cda37f4e5829462c7e489f85bf327ccovener script matching the request, if this has already
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim been determined by the server at the time
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim <code>REQUEST_FILENAME</code> is referenced. Otherwise,
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim such as when used in virtual host context, the same
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coar value as <code>REQUEST_URI</code>. Depending on the value of
9153a696314d93c5dcdd2539d7d9ebf746ecd77dcovener <directive module="core">AcceptPathInfo</directive>, the
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coar server may have only used some leading components of the
7b9b6d4364d3a3676959ba353cd43c6f05295682covener <code>REQUEST_URI</code> to map the request to a file.
9153a696314d93c5dcdd2539d7d9ebf746ecd77dcovener </dd>
7748a5c411233f9e1f3df10ea5fffffa91e58824jorton
4203a35c28d7c60adb7e9ef3be87aad34951c79asf <dt><code>REQUEST_SCHEME</code></dt>
4203a35c28d7c60adb7e9ef3be87aad34951c79asf
ff165e24f20fdebbe3651ed6aee03d7e13299d35humbedooh <dd>Will contain the scheme of the request (usually
4203a35c28d7c60adb7e9ef3be87aad34951c79asf "http" or "https"). This value can be influenced with
4203a35c28d7c60adb7e9ef3be87aad34951c79asf <directive module="core">ServerName</directive>.</dd>
4203a35c28d7c60adb7e9ef3be87aad34951c79asf
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc <dt><code>REQUEST_URI</code></dt>
a4bcadc43f29245972e9e8745a5114610065329ccovener
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc <dd>The path component of the requested URI,
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc such as "/index.html". This notably excludes the
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc query string which is available as as its own variable
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc named <code>QUERY_STRING</code>.</dd>
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc <dt><code>THE_REQUEST</code></dt>
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc <dd>The full HTTP request line sent by the
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc browser to the server (e.g., "<code>GET
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc /index.html HTTP/1.1</code>"). This does not
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc include any additional headers sent by the
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc browser. This value has not been unescaped
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc (decoded), unlike most other variables below.</dd>
a4bcadc43f29245972e9e8745a5114610065329ccovener
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </dl>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</note>
fa0f379e3845907d7c1087d885169e302239bdbbnd </li>
fa0f379e3845907d7c1087d885169e302239bdbbnd </ul>
fa0f379e3845907d7c1087d885169e302239bdbbnd
491809c1661a323205c91df21e69225cc3d6e37bsf <p>If the <em>TestString</em> has the special value <code>expr</code>,
491809c1661a323205c91df21e69225cc3d6e37bsf the <em>CondPattern</em> will be treated as an
491809c1661a323205c91df21e69225cc3d6e37bsf <a href="/expr.html">ap_expr</a>. HTTP headers referenced in the
491809c1661a323205c91df21e69225cc3d6e37bsf expression will be added to the Vary header if the <code>novary</code>
491809c1661a323205c91df21e69225cc3d6e37bsf flag is not given.</p>
c094add0a23fe1120fd33711ba2e2d084f5629a1sf
fa0f379e3845907d7c1087d885169e302239bdbbnd <p>Other things you should be aware of:</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
fa0f379e3845907d7c1087d885169e302239bdbbnd <ol>
fa0f379e3845907d7c1087d885169e302239bdbbnd <li>
fa0f379e3845907d7c1087d885169e302239bdbbnd <p>The variables SCRIPT_FILENAME and REQUEST_FILENAME
fa0f379e3845907d7c1087d885169e302239bdbbnd contain the same value - the value of the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>filename</code> field of the internal
cea021a7fc2657b091df4d3b031c4254ec371dd7rbowen <code>request_rec</code> structure of the Apache HTTP Server.
fa0f379e3845907d7c1087d885169e302239bdbbnd The first name is the commonly known CGI variable name
fa0f379e3845907d7c1087d885169e302239bdbbnd while the second is the appropriate counterpart of
fa0f379e3845907d7c1087d885169e302239bdbbnd REQUEST_URI (which contains the value of the
fa0f379e3845907d7c1087d885169e302239bdbbnd <code>uri</code> field of <code>request_rec</code>).</p>
fa0f379e3845907d7c1087d885169e302239bdbbnd <p>If a substitution occurred and the rewriting continues,
fa0f379e3845907d7c1087d885169e302239bdbbnd the value of both variables will be updated accordingly.</p>
fa0f379e3845907d7c1087d885169e302239bdbbnd <p>If used in per-server context (<em>i.e.</em>, before the
fa0f379e3845907d7c1087d885169e302239bdbbnd request is mapped to the filesystem) SCRIPT_FILENAME and
fa0f379e3845907d7c1087d885169e302239bdbbnd REQUEST_FILENAME cannot contain the full local filesystem
fa0f379e3845907d7c1087d885169e302239bdbbnd path since the path is unknown at this stage of processing.
fa0f379e3845907d7c1087d885169e302239bdbbnd Both variables will initially contain the value of REQUEST_URI
fa0f379e3845907d7c1087d885169e302239bdbbnd in that case. In order to obtain the full local filesystem
fa0f379e3845907d7c1087d885169e302239bdbbnd path of the request in per-server context, use an URL-based
a4d04b8c74044c58bd4182028a1408d936c95951covener look-ahead <code>%{LA-U:REQUEST_FILENAME}</code> to determine
fa0f379e3845907d7c1087d885169e302239bdbbnd the final value of REQUEST_FILENAME.</p></li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
fa0f379e3845907d7c1087d885169e302239bdbbnd <li>
fa0f379e3845907d7c1087d885169e302239bdbbnd <code>%{ENV:variable}</code>, where <em>variable</em> can be
fa0f379e3845907d7c1087d885169e302239bdbbnd any environment variable, is also available.
fa0f379e3845907d7c1087d885169e302239bdbbnd This is looked-up via internal
cea021a7fc2657b091df4d3b031c4254ec371dd7rbowen Apache httpd structures and (if not found there) via
cea021a7fc2657b091df4d3b031c4254ec371dd7rbowen <code>getenv()</code> from the Apache httpd server process.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin <li>
fa0f379e3845907d7c1087d885169e302239bdbbnd <code>%{SSL:variable}</code>, where <em>variable</em> is the
7748a5c411233f9e1f3df10ea5fffffa91e58824jorton name of an <a href="mod_ssl.html#envvars">SSL environment
fa0f379e3845907d7c1087d885169e302239bdbbnd variable</a>, can be used whether or not
fa0f379e3845907d7c1087d885169e302239bdbbnd <module>mod_ssl</module> is loaded, but will always expand to
fa0f379e3845907d7c1087d885169e302239bdbbnd the empty string if it is not. Example:
fa0f379e3845907d7c1087d885169e302239bdbbnd <code>%{SSL:SSL_CIPHER_USEKEYSIZE}</code> may expand to
fa0f379e3845907d7c1087d885169e302239bdbbnd <code>128</code>.</li>
fa0f379e3845907d7c1087d885169e302239bdbbnd
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin <li>
fa0f379e3845907d7c1087d885169e302239bdbbnd <code>%{HTTP:header}</code>, where <em>header</em> can be
fa0f379e3845907d7c1087d885169e302239bdbbnd any HTTP MIME-header name, can always be used to obtain the
fa0f379e3845907d7c1087d885169e302239bdbbnd value of a header sent in the HTTP request.
fa0f379e3845907d7c1087d885169e302239bdbbnd Example: <code>%{HTTP:Proxy-Connection}</code> is
fa0f379e3845907d7c1087d885169e302239bdbbnd the value of the HTTP header
fa0f379e3845907d7c1087d885169e302239bdbbnd ``<code>Proxy-Connection:</code>''.
fa0f379e3845907d7c1087d885169e302239bdbbnd <p>If a HTTP header is used in a condition this header is added to
37c26549741cbbff3874b385ee5540924a8b37fcjailletc the Vary header of the response in case the condition evaluates
fa0f379e3845907d7c1087d885169e302239bdbbnd to true for the request. It is <strong>not</strong> added if the
fa0f379e3845907d7c1087d885169e302239bdbbnd condition evaluates to false for the request. Adding the HTTP header
fa0f379e3845907d7c1087d885169e302239bdbbnd to the Vary header of the response is needed for proper caching.</p>
fa0f379e3845907d7c1087d885169e302239bdbbnd <p>It has to be kept in mind that conditions follow a short circuit
fa0f379e3845907d7c1087d885169e302239bdbbnd logic in the case of the '<strong><code>ornext|OR</code></strong>' flag
fa0f379e3845907d7c1087d885169e302239bdbbnd so that certain conditions might not be evaluated at all.</p></li>
fa0f379e3845907d7c1087d885169e302239bdbbnd
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin <li>
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coar <a id="LA-U" name="LA-U"><code>%{LA-U:variable}</code></a>
025dc11c0fd8d6a7fdb5f0a46cc3a5fbab64b93drbowen can be used for look-aheads which perform
fa0f379e3845907d7c1087d885169e302239bdbbnd an internal (URL-based) sub-request to determine the final
fa0f379e3845907d7c1087d885169e302239bdbbnd value of <em>variable</em>. This can be used to access
fa0f379e3845907d7c1087d885169e302239bdbbnd variable for rewriting which is not available at the current
fa0f379e3845907d7c1087d885169e302239bdbbnd stage, but will be set in a later phase.
fa0f379e3845907d7c1087d885169e302239bdbbnd <p>For instance, to rewrite according to the
fa0f379e3845907d7c1087d885169e302239bdbbnd <code>REMOTE_USER</code> variable from within the
fa0f379e3845907d7c1087d885169e302239bdbbnd per-server context (<code>httpd.conf</code> file) you must
fa0f379e3845907d7c1087d885169e302239bdbbnd use <code>%{LA-U:REMOTE_USER}</code> - this
fa0f379e3845907d7c1087d885169e302239bdbbnd variable is set by the authorization phases, which come
fa0f379e3845907d7c1087d885169e302239bdbbnd <em>after</em> the URL translation phase (during which mod_rewrite
fa0f379e3845907d7c1087d885169e302239bdbbnd operates).</p>
fa0f379e3845907d7c1087d885169e302239bdbbnd <p>On the other hand, because mod_rewrite implements
fa0f379e3845907d7c1087d885169e302239bdbbnd its per-directory context (<code>.htaccess</code> file) via
fa0f379e3845907d7c1087d885169e302239bdbbnd the Fixup phase of the API and because the authorization
fa0f379e3845907d7c1087d885169e302239bdbbnd phases come <em>before</em> this phase, you just can use
fa0f379e3845907d7c1087d885169e302239bdbbnd <code>%{REMOTE_USER}</code> in that context.</p></li>
fa0f379e3845907d7c1087d885169e302239bdbbnd
fa0f379e3845907d7c1087d885169e302239bdbbnd <li>
fa0f379e3845907d7c1087d885169e302239bdbbnd <code>%{LA-F:variable}</code> can be used to perform an internal
fa0f379e3845907d7c1087d885169e302239bdbbnd (filename-based) sub-request, to determine the final value
fa0f379e3845907d7c1087d885169e302239bdbbnd of <em>variable</em>. Most of the time, this is the same as
fa0f379e3845907d7c1087d885169e302239bdbbnd LA-U above.</li>
fa0f379e3845907d7c1087d885169e302239bdbbnd </ol>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p><em>CondPattern</em> is the condition pattern,
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin a regular expression which is applied to the
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin current instance of the <em>TestString</em>.
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin <em>TestString</em> is first evaluated, before being matched against
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em>CondPattern</em>.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <p><em>CondPattern</em> is usually a
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <em>perl compatible regular expression</em>, but there is
88f586e767b7b224bdb1a178455668a2475cfc75rbowen additional syntax available to perform other useful tests against
88f586e767b7b224bdb1a178455668a2475cfc75rbowen the <em>Teststring</em>:</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <ol>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>You can prefix the pattern string with a
b2e020677d1f9cd5c8e3a6b612d022a0515ad298covener '<code>!</code>' character (exclamation mark) to negate the result
b2e020677d1f9cd5c8e3a6b612d022a0515ad298covener of the condition, no matter what kind of <em>CondPattern</em> is used.
b2e020677d1f9cd5c8e3a6b612d022a0515ad298covener </li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>
88f586e767b7b224bdb1a178455668a2475cfc75rbowen You can perform lexicographical string comparisons:
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <ul>
5f18f92c1354462df6dc2ba38277a953fa700b13gryzor <li>'<strong>&lt;CondPattern</strong>' (lexicographically
206b5dce9e48924aa9f12ce87f14856a4cd3fb68takashi precedes)<br />
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin Treats the <em>CondPattern</em> as a plain string and
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin compares it lexicographically to <em>TestString</em>. True if
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin <em>TestString</em> lexicographically precedes
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em>CondPattern</em>.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin <li>'<strong>&gt;CondPattern</strong>' (lexicographically
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin follows)<br />
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin Treats the <em>CondPattern</em> as a plain string and
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin compares it lexicographically to <em>TestString</em>. True if
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin <em>TestString</em> lexicographically follows
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em>CondPattern</em>.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin <li>'<strong>=CondPattern</strong>' (lexicographically
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive equal)<br />
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin Treats the <em>CondPattern</em> as a plain string and
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin compares it lexicographically to <em>TestString</em>. True if
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin <em>TestString</em> is lexicographically equal to
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin <em>CondPattern</em> (the two strings are exactly
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin equal, character for character). If <em>CondPattern</em>
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin is <code>""</code> (two quotation marks) this
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive compares <em>TestString</em> to the empty string.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen <li>'<strong>&lt;=CondPattern</strong>' (lexicographically
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen less than or equal to)<br />
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen Treats the <em>CondPattern</em> as a plain string and
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen compares it lexicographically to <em>TestString</em>. True
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen if <em>TestString</em> lexicographically precedes
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen <em>CondPattern</em>, or is equal to <em>CondPattern</em>
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen (the two strings are equal, character for character).</li>
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen <li>'<strong>&gt;=CondPattern</strong>' (lexicographically
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen greater than or equal to)<br />
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen Treats the <em>CondPattern</em> as a plain string and
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen compares it lexicographically to <em>TestString</em>. True
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen if <em>TestString</em> lexicographically follows
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen <em>CondPattern</em>, or is equal to <em>CondPattern</em>
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen (the two strings are equal, character for character).</li>
88f586e767b7b224bdb1a178455668a2475cfc75rbowen </ul></li>
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <li>
88f586e767b7b224bdb1a178455668a2475cfc75rbowen You can perform integer comparisons:
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <ul>
88f586e767b7b224bdb1a178455668a2475cfc75rbowen
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <li>'<strong>-eq</strong>' (is numerically
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <strong>eq</strong>ual to)<br />
88f586e767b7b224bdb1a178455668a2475cfc75rbowen The <em>TestString</em> is treated as an integer, and is
88f586e767b7b224bdb1a178455668a2475cfc75rbowen numerically compared to the <em>CondPattern</em>. True if
88f586e767b7b224bdb1a178455668a2475cfc75rbowen the two are numerically equal.</li>
88f586e767b7b224bdb1a178455668a2475cfc75rbowen
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <li>'<strong>-ge</strong>' (is numerically
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <strong>g</strong>reater than or <strong>e</strong>qual to)<br />
88f586e767b7b224bdb1a178455668a2475cfc75rbowen The <em>TestString</em> is treated as an integer, and is
88f586e767b7b224bdb1a178455668a2475cfc75rbowen numerically compared to the <em>CondPattern</em>. True if
88f586e767b7b224bdb1a178455668a2475cfc75rbowen the <em>TestString</em> is numerically greater than or equal
88f586e767b7b224bdb1a178455668a2475cfc75rbowen to the <em>CondPattern</em>.</li>
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <li>'<strong>-gt</strong>' (is numerically
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <strong>g</strong>reater <strong>t</strong>han)<br />
88f586e767b7b224bdb1a178455668a2475cfc75rbowen The <em>TestString</em> is treated as an integer, and is
88f586e767b7b224bdb1a178455668a2475cfc75rbowen numerically compared to the <em>CondPattern</em>. True if
88f586e767b7b224bdb1a178455668a2475cfc75rbowen the <em>TestString</em> is numerically greater than
88f586e767b7b224bdb1a178455668a2475cfc75rbowen the <em>CondPattern</em>.</li>
88f586e767b7b224bdb1a178455668a2475cfc75rbowen
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <li>'<strong>-le</strong>' (is numerically
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <strong>l</strong>ess than or <strong>e</strong>qual to)<br />
88f586e767b7b224bdb1a178455668a2475cfc75rbowen The <em>TestString</em> is treated as an integer, and is
88f586e767b7b224bdb1a178455668a2475cfc75rbowen numerically compared to the <em>CondPattern</em>. True if
88f586e767b7b224bdb1a178455668a2475cfc75rbowen the <em>TestString</em> is numerically less than or equal
88f586e767b7b224bdb1a178455668a2475cfc75rbowen to the <em>CondPattern</em>. Avoid confusion with the
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <strong>-l</strong> by using the <strong>-L</strong> or
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <strong>-h</strong> variant.</li>
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <li>'<strong>-lt</strong>' (is numerically
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <strong>l</strong>ess <strong>t</strong>han)<br />
88f586e767b7b224bdb1a178455668a2475cfc75rbowen The <em>TestString</em> is treated as an integer, and is
88f586e767b7b224bdb1a178455668a2475cfc75rbowen numerically compared to the <em>CondPattern</em>. True if
88f586e767b7b224bdb1a178455668a2475cfc75rbowen the <em>TestString</em> is numerically less than
88f586e767b7b224bdb1a178455668a2475cfc75rbowen the <em>CondPattern</em>. Avoid confusion with the
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <strong>-l</strong> by using the <strong>-L</strong> or
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <strong>-h</strong> variant.</li>
88f586e767b7b224bdb1a178455668a2475cfc75rbowen
88f586e767b7b224bdb1a178455668a2475cfc75rbowen </ul>
88f586e767b7b224bdb1a178455668a2475cfc75rbowen </li>
88f586e767b7b224bdb1a178455668a2475cfc75rbowen
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <li>You can perform various file attribute tests:
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <ul>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>'<strong>-d</strong>' (is
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <strong>d</strong>irectory)<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive Treats the <em>TestString</em> as a pathname and tests
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin whether or not it exists, and is a directory.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>'<strong>-f</strong>' (is regular
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <strong>f</strong>ile)<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive Treats the <em>TestString</em> as a pathname and tests
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin whether or not it exists, and is a regular file.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin <li>'<strong>-F</strong>' (is existing file, via
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive subrequest)<br />
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin Checks whether or not <em>TestString</em> is a valid file,
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive accessible via all the server's currently-configured
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive access controls for that path. This uses an internal
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin subrequest to do the check, so use it with care -
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin it can impact your server's performance!</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen <li>'<strong>-H</strong>' (is symbolic link, bash convention)<br />
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen See <strong>-l</strong>.</li>
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen <li>'<strong>-l</strong>' (is symbolic
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen <strong>l</strong>ink)<br />
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen Treats the <em>TestString</em> as a pathname and tests
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen whether or not it exists, and is a symbolic link. May also
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen use the bash convention of <strong>-L</strong> or
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen <strong>-h</strong> if there's a possibility of confusion
88f586e767b7b224bdb1a178455668a2475cfc75rbowen such as when using the <strong>-lt</strong> or
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <strong>-le</strong> tests.</li>
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen <li>'<strong>-L</strong>' (is symbolic link, bash convention)<br />
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen See <strong>-l</strong>.</li>
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen <li>'<strong>-s</strong>' (is regular file, with
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen <strong>s</strong>ize)<br />
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen Treats the <em>TestString</em> as a pathname and tests
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen whether or not it exists, and is a regular file with size greater
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen than zero.</li>
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen
60177b97ef90c0dfb6e45d2d38c609d488ef6315covener <li><p>'<strong>-U</strong>' (is existing URL, via
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive subrequest)<br />
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin Checks whether or not <em>TestString</em> is a valid URL,
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive accessible via all the server's currently-configured
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive access controls for that path. This uses an internal
5f18f92c1354462df6dc2ba38277a953fa700b13gryzor subrequest to do the check, so use it with care -
60177b97ef90c0dfb6e45d2d38c609d488ef6315covener it can impact your server's performance!</p>
60177b97ef90c0dfb6e45d2d38c609d488ef6315covener <p> This flag <em>only</em> returns information about things
60177b97ef90c0dfb6e45d2d38c609d488ef6315covener like access control, authentication, and authorization. This flag
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coar <em>does not</em> return information about the status code the
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coar configured handler (static file, CGI, proxy, etc.) would have
60177b97ef90c0dfb6e45d2d38c609d488ef6315covener returned.</p> </li>
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen <li>'<strong>-x</strong>' (has e<strong>x</strong>ecutable
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen permissions)<br />
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen Treats the <em>TestString</em> as a pathname and tests
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen whether or not it exists, and has executable permissions.
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen These permissions are determined according to
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen the underlying OS.</li>
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </ul>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
c094add0a23fe1120fd33711ba2e2d084f5629a1sf <li>
c094add0a23fe1120fd33711ba2e2d084f5629a1sf <p>If the <em>TestString</em> has the special value <code>expr</code>, the
c0c1f9ffbf550e6ba5e60d2d0ee55490794f3aefrbowen <em>CondPattern</em> will be treated as an
c094add0a23fe1120fd33711ba2e2d084f5629a1sf <a href="/expr.html">ap_expr</a>.</p>
44af3968bb363f5a956a86cc90e591384a2f07b5rbowen
44af3968bb363f5a956a86cc90e591384a2f07b5rbowen <p>
44af3968bb363f5a956a86cc90e591384a2f07b5rbowen In the below example, <code>-strmatch</code> is used to
44af3968bb363f5a956a86cc90e591384a2f07b5rbowen compare the <code>REFERER</code> against the site hostname,
44af3968bb363f5a956a86cc90e591384a2f07b5rbowen to block unwanted hotlinking.
44af3968bb363f5a956a86cc90e591384a2f07b5rbowen </p>
44af3968bb363f5a956a86cc90e591384a2f07b5rbowen
3a257106808eabaefbb483bdc6273e7af062ead8humbedooh <highlight language="config">
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coarRewriteCond expr "! %{HTTP_REFERER} -strmatch '*://%{HTTP_HOST}/*'"<br />
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coarRewriteRule "^/images" "-" [F]
3a257106808eabaefbb483bdc6273e7af062ead8humbedooh </highlight>
c094add0a23fe1120fd33711ba2e2d084f5629a1sf </li>
c094add0a23fe1120fd33711ba2e2d084f5629a1sf
206b5dce9e48924aa9f12ce87f14856a4cd3fb68takashi <li>You can also set special flags for
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin <em>CondPattern</em> by appending
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <strong><code>[</code><em>flags</em><code>]</code></strong>
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin as the third argument to the <code>RewriteCond</code>
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin directive, where <em>flags</em> is a comma-separated list of any of the
5a4ba75a85817ca324e4f054d56f42a6a14adc5dnd following flags:
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <ul>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>'<strong><code>nocase|NC</code></strong>'
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive (<strong>n</strong>o <strong>c</strong>ase)<br />
5f18f92c1354462df6dc2ba38277a953fa700b13gryzor This makes the test case-insensitive - differences
206b5dce9e48924aa9f12ce87f14856a4cd3fb68takashi between 'A-Z' and 'a-z' are ignored, both in the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive expanded <em>TestString</em> and the <em>CondPattern</em>.
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive This flag is effective only for comparisons between
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em>TestString</em> and <em>CondPattern</em>. It has no
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive effect on filesystem and subrequest checks.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive '<strong><code>ornext|OR</code></strong>'
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive (<strong>or</strong> next condition)<br />
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin Use this to combine rule conditions with a local OR
5f18f92c1354462df6dc2ba38277a953fa700b13gryzor instead of the implicit AND. Typical example:
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
3a257106808eabaefbb483bdc6273e7af062ead8humbedooh<highlight language="config">
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coarRewriteCond "%{REMOTE_HOST}" "^host1" [OR]
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coarRewriteCond "%{REMOTE_HOST}" "^host2" [OR]
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coarRewriteCond "%{REMOTE_HOST}" "^host3"
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfsliveRewriteRule ...some special stuff for any of these hosts...
3a257106808eabaefbb483bdc6273e7af062ead8humbedooh</highlight>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin Without this flag you would have to write the condition/rule
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin pair three times.
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </li>
b65a184929c97d0b0e4d3bad42648e0e9ce1b8ferpluem
b65a184929c97d0b0e4d3bad42648e0e9ce1b8ferpluem <li>'<strong><code>novary|NV</code></strong>'
b65a184929c97d0b0e4d3bad42648e0e9ce1b8ferpluem (<strong>n</strong>o <strong>v</strong>ary)<br />
b65a184929c97d0b0e4d3bad42648e0e9ce1b8ferpluem If a HTTP header is used in the condition, this flag prevents
b65a184929c97d0b0e4d3bad42648e0e9ce1b8ferpluem this header from being added to the Vary header of the response. <br />
b65a184929c97d0b0e4d3bad42648e0e9ce1b8ferpluem Using this flag might break proper caching of the response if
b65a184929c97d0b0e4d3bad42648e0e9ce1b8ferpluem the representation of this response varies on the value of this header.
b65a184929c97d0b0e4d3bad42648e0e9ce1b8ferpluem So this flag should be only used if the meaning of the Vary header
b65a184929c97d0b0e4d3bad42648e0e9ce1b8ferpluem is well understood.
b65a184929c97d0b0e4d3bad42648e0e9ce1b8ferpluem </li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </ul>
5a4ba75a85817ca324e4f054d56f42a6a14adc5dnd </li>
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin </ol>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p><strong>Example:</strong></p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>To rewrite the Homepage of a site according to the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive ``<code>User-Agent:</code>'' header of the request, you can
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive use the following: </p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
3a257106808eabaefbb483bdc6273e7af062ead8humbedooh<highlight language="config">
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coarRewriteCond "%{HTTP_USER_AGENT}" "(iPhone|Blackberry|Android)"
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coarRewriteRule "^/$" "/homepage.mobile.html" [L]
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coarRewriteRule "^/$" "/homepage.std.html" [L]
3a257106808eabaefbb483bdc6273e7af062ead8humbedooh</highlight>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
5f18f92c1354462df6dc2ba38277a953fa700b13gryzor <p>Explanation: If you use a browser which identifies itself
8ae7b19a7c6b1415b2be0b45e91d7ba6e8ed010drbowen as a mobile browser (note that the example is incomplete, as
8ae7b19a7c6b1415b2be0b45e91d7ba6e8ed010drbowen there are many other mobile platforms), the mobile version of
8ae7b19a7c6b1415b2be0b45e91d7ba6e8ed010drbowen the homepage is served. Otherwise, the standard page is served.
8ae7b19a7c6b1415b2be0b45e91d7ba6e8ed010drbowen </p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</usage>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</directivesynopsis>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<directivesynopsis>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<name>RewriteRule</name>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<description>Defines rules for the rewriting engine</description>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<syntax>RewriteRule
96147932f199be4ad038778e702c13a2f79051c0slive <em>Pattern</em> <em>Substitution</em> [<em>flags</em>]</syntax>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<contextlist><context>server config</context><context>virtual host</context>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<context>directory</context><context>.htaccess</context></contextlist>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<override>FileInfo</override>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<usage>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>The <directive>RewriteRule</directive> directive is the real
5f18f92c1354462df6dc2ba38277a953fa700b13gryzor rewriting workhorse. The directive can occur more than once,
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin with each instance defining a single rewrite rule. The
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin order in which these rules are defined is important - this is the order
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin in which they will be applied at run-time.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
630c456b6461158be6cc5c5483735e27b13b4ad5nd <p><a id="patterns" name="patterns"><em>Pattern</em></a> is
630c456b6461158be6cc5c5483735e27b13b4ad5nd a perl compatible <a id="regexp" name="regexp">regular
4e9c3b56a42ce3d88366146f3f71194f64148447humbedooh expression</a>. On the first RewriteRule, it is matched against
efe651a6cb549595d56664790a170c19f3a11fafrbowen the (%-decoded) <a href="directive-dict.html#Syntax">URL-path</a>
efe651a6cb549595d56664790a170c19f3a11fafrbowen of the request, or, in per-directory context (see below), the URL
efe651a6cb549595d56664790a170c19f3a11fafrbowen path relative to that per-directory context. Subsequent patterns
efe651a6cb549595d56664790a170c19f3a11fafrbowen are matched against the output of the last matching RewriteRule.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
81fb9d8829c87f498aad9ae764e98d1f60fbfd1crbowen<note><title><a id="what_is_matched" name="what_is_matched">What is matched?</a></title>
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim <p>In <directive module="core">VirtualHost</directive> context,
944950774d28288e298c396e6f06fa4ba18e4ca0covener The <em>Pattern</em> will initially be matched against the part of the
944950774d28288e298c396e6f06fa4ba18e4ca0covener URL after the hostname and port, and before the query string (e.g. "/app1/index.html").</p>
944950774d28288e298c396e6f06fa4ba18e4ca0covener
944950774d28288e298c396e6f06fa4ba18e4ca0covener <p>In <directive module="core">Directory</directive> and htaccess context,
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim the <em>Pattern</em> will initially be matched against the
2099e7c30b65c2015f24fdc9b9c5e23414467d0ahumbedooh <em>filesystem</em> path, after removing the prefix that led the server
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim to the current <directive>RewriteRule</directive> (e.g. "app1/index.html"
944950774d28288e298c396e6f06fa4ba18e4ca0covener or "index.html" depending on where the directives are defined).</p>
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim
e619b7228ac42d9c70d6a5f02d808b0d2880080ccovener <p>If you wish to match against the hostname, port, or query string, use a
96147932f199be4ad038778e702c13a2f79051c0slive <directive module="mod_rewrite">RewriteCond</directive> with the
96147932f199be4ad038778e702c13a2f79051c0slive <code>%{HTTP_HOST}</code>, <code>%{SERVER_PORT}</code>, or
944950774d28288e298c396e6f06fa4ba18e4ca0covener <code>%{QUERY_STRING}</code> variables respectively.</p>
944950774d28288e298c396e6f06fa4ba18e4ca0covener
944950774d28288e298c396e6f06fa4ba18e4ca0covener</note>
e619b7228ac42d9c70d6a5f02d808b0d2880080ccovener
944950774d28288e298c396e6f06fa4ba18e4ca0covener<note><title>Per-directory Rewrites</title>
944950774d28288e298c396e6f06fa4ba18e4ca0covener<ul>
944950774d28288e298c396e6f06fa4ba18e4ca0covener<li>The rewrite engine may be used in <a
25685ff9c2ac6ff8876a4d23bc6091432310f307covenerhref="/howto/htaccess.html">.htaccess</a> files and in <directive type="section"
944950774d28288e298c396e6f06fa4ba18e4ca0covenermodule="core">Directory</directive> sections, with some additional
944950774d28288e298c396e6f06fa4ba18e4ca0covenercomplexity.</li>
944950774d28288e298c396e6f06fa4ba18e4ca0covener
944950774d28288e298c396e6f06fa4ba18e4ca0covener<li>To enable the rewrite engine in this context, you need to set
944950774d28288e298c396e6f06fa4ba18e4ca0covener"<code>RewriteEngine On</code>" <strong>and</strong>
944950774d28288e298c396e6f06fa4ba18e4ca0covener"<code>Options FollowSymLinks</code>" must be enabled. If your
944950774d28288e298c396e6f06fa4ba18e4ca0coveneradministrator has disabled override of <code>FollowSymLinks</code> for
944950774d28288e298c396e6f06fa4ba18e4ca0covenera user's directory, then you cannot use the rewrite engine. This
944950774d28288e298c396e6f06fa4ba18e4ca0covenerrestriction is required for security reasons.</li>
944950774d28288e298c396e6f06fa4ba18e4ca0covener
944950774d28288e298c396e6f06fa4ba18e4ca0covener<li>When using the rewrite engine in <code>.htaccess</code> files the
944950774d28288e298c396e6f06fa4ba18e4ca0covenerper-directory prefix (which always is the same for a specific
cb85fb2fa6a3fd1fea1eda25ffc2a62190f0ff9crbowendirectory) is automatically <em>removed</em> for the RewriteRule pattern matching
944950774d28288e298c396e6f06fa4ba18e4ca0covenerand automatically <em>added</em> after any relative (not starting with a
cb85fb2fa6a3fd1fea1eda25ffc2a62190f0ff9crbowenslash or protocol name) substitution encounters the end of a rule set.
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jimSee the <directive module="mod_rewrite">RewriteBase</directive>
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jimdirective for more information regarding what prefix will be added back to
dbe68b8c92b9bd76e692c045d52820cb55efd6abrbowenrelative substitutions.</li>
944950774d28288e298c396e6f06fa4ba18e4ca0covener
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim<li> If you wish to match against the full URL-path in a per-directory
944950774d28288e298c396e6f06fa4ba18e4ca0covener(htaccess) RewriteRule, use the <code>%{REQUEST_URI}</code> variable in
944950774d28288e298c396e6f06fa4ba18e4ca0covenera <directive>RewriteCond</directive>.</li>
944950774d28288e298c396e6f06fa4ba18e4ca0covener
944950774d28288e298c396e6f06fa4ba18e4ca0covener<li>The removed prefix always ends with a slash, meaning the matching occurs against a string which
25685ff9c2ac6ff8876a4d23bc6091432310f307covener<em>never</em> has a leading slash. Therefore, a <em>Pattern</em> with <code>^/</code> never
944950774d28288e298c396e6f06fa4ba18e4ca0covenermatches in per-directory context.</li>
944950774d28288e298c396e6f06fa4ba18e4ca0covener
944950774d28288e298c396e6f06fa4ba18e4ca0covener<li>Although rewrite rules are syntactically permitted in <directive
944950774d28288e298c396e6f06fa4ba18e4ca0covenertype="section" module="core">Location</directive> and <directive
37c8bbe89a8f9376b7686a1419c36748f7076d23covenertype="section" module="core">Files</directive> sections
37c8bbe89a8f9376b7686a1419c36748f7076d23covener(including their regular expression counterparts), this
37c8bbe89a8f9376b7686a1419c36748f7076d23covenershould never be necessary and is unsupported. A likely feature
37c8bbe89a8f9376b7686a1419c36748f7076d23covenerto break in these contexts is relative substitutions.</li>
944950774d28288e298c396e6f06fa4ba18e4ca0covener</ul>
96147932f199be4ad038778e702c13a2f79051c0slive</note>
96147932f199be4ad038778e702c13a2f79051c0slive
70f2730533c8592263435354e66d9dbaf4d6361bslive <p>For some hints on <glossary ref="regex">regular
70f2730533c8592263435354e66d9dbaf4d6361bslive expressions</glossary>, see
1093a264c81aa1041581ab059905fb8f7cdfc5e2rbowen the <a href="/rewrite/intro.html#regex">mod_rewrite
70f2730533c8592263435354e66d9dbaf4d6361bslive Introduction</a>.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
206b5dce9e48924aa9f12ce87f14856a4cd3fb68takashi <p>In mod_rewrite, the NOT character
5f18f92c1354462df6dc2ba38277a953fa700b13gryzor ('<code>!</code>') is also available as a possible pattern
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin prefix. This enables you to negate a pattern; to say, for instance:
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive ``<em>if the current URL does <strong>NOT</strong> match this
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive pattern</em>''. This can be used for exceptional cases, where
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive it is easier to match the negative pattern, or as a last
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive default rule.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin<note><title>Note</title>
5f18f92c1354462df6dc2ba38277a953fa700b13gryzorWhen using the NOT character to negate a pattern, you cannot include
5f18f92c1354462df6dc2ba38277a953fa700b13gryzorgrouped wildcard parts in that pattern. This is because, when the
5f18f92c1354462df6dc2ba38277a953fa700b13gryzorpattern does NOT match (ie, the negation matches), there are no
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirincontents for the groups. Thus, if negated patterns are used, you
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirincannot use <code>$N</code> in the substitution string!
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</note>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
96147932f199be4ad038778e702c13a2f79051c0slive <p>The <a id="rhs" name="rhs"><em>Substitution</em></a> of a
96147932f199be4ad038778e702c13a2f79051c0slive rewrite rule is the string that replaces the original URL-path that
96147932f199be4ad038778e702c13a2f79051c0slive was matched by <em>Pattern</em>. The <em>Substitution</em> may
96147932f199be4ad038778e702c13a2f79051c0slive be a:</p>
96147932f199be4ad038778e702c13a2f79051c0slive
96147932f199be4ad038778e702c13a2f79051c0slive <dl>
96147932f199be4ad038778e702c13a2f79051c0slive
96147932f199be4ad038778e702c13a2f79051c0slive <dt>file-system path</dt>
96147932f199be4ad038778e702c13a2f79051c0slive
96147932f199be4ad038778e702c13a2f79051c0slive <dd>Designates the location on the file-system of the resource
c83db09d27363318d4c595564937d199ac6cbf71covener to be delivered to the client. Substitutions are only
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coar treated as a file-system path when the rule is configured in
c83db09d27363318d4c595564937d199ac6cbf71covener server (virtualhost) context and the first component of the
dabdff4f01f31a31f3c96a3157f25dea49a1cf32humbedooh path in the substitution exists in the file-system</dd>
96147932f199be4ad038778e702c13a2f79051c0slive
5f18f92c1354462df6dc2ba38277a953fa700b13gryzor <dt>URL-path</dt>
96147932f199be4ad038778e702c13a2f79051c0slive
96147932f199be4ad038778e702c13a2f79051c0slive <dd>A <directive
96147932f199be4ad038778e702c13a2f79051c0slive module="core">DocumentRoot</directive>-relative path to the
96147932f199be4ad038778e702c13a2f79051c0slive resource to be served. Note that <module>mod_rewrite</module>
96147932f199be4ad038778e702c13a2f79051c0slive tries to guess whether you have specified a file-system path
45309cf90ecc60d20e1ac810881e7b149fbe4e35noodl or a URL-path by checking to see if the first segment of the
96147932f199be4ad038778e702c13a2f79051c0slive path exists at the root of the file-system. For example, if
96147932f199be4ad038778e702c13a2f79051c0slive you specify a <em>Substitution</em> string of
96147932f199be4ad038778e702c13a2f79051c0slive <code>/www/file.html</code>, then this will be treated as a
96147932f199be4ad038778e702c13a2f79051c0slive URL-path <em>unless</em> a directory named <code>www</code>
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coar exists at the root or your file-system (or, in the case of
80b223c8e14db3a06c6d1776b92c55a2257b31bbhumbedooh using rewrites in a <code>.htaccess</code> file, relative to
80b223c8e14db3a06c6d1776b92c55a2257b31bbhumbedooh your document root), in which case it will
96147932f199be4ad038778e702c13a2f79051c0slive be treated as a file-system path. If you wish other
96147932f199be4ad038778e702c13a2f79051c0slive URL-mapping directives (such as <directive
96147932f199be4ad038778e702c13a2f79051c0slive module="mod_alias">Alias</directive>) to be applied to the
96147932f199be4ad038778e702c13a2f79051c0slive resulting URL-path, use the <code>[PT]</code> flag as
96147932f199be4ad038778e702c13a2f79051c0slive described below.</dd>
96147932f199be4ad038778e702c13a2f79051c0slive
96147932f199be4ad038778e702c13a2f79051c0slive <dt>Absolute URL</dt>
96147932f199be4ad038778e702c13a2f79051c0slive
96147932f199be4ad038778e702c13a2f79051c0slive <dd>If an absolute URL is specified,
96147932f199be4ad038778e702c13a2f79051c0slive <module>mod_rewrite</module> checks to see whether the
96147932f199be4ad038778e702c13a2f79051c0slive hostname matches the current host. If it does, the scheme and
96147932f199be4ad038778e702c13a2f79051c0slive hostname are stripped out and the resulting path is treated as
96147932f199be4ad038778e702c13a2f79051c0slive a URL-path. Otherwise, an external redirect is performed for
96147932f199be4ad038778e702c13a2f79051c0slive the given URL. To force an external redirect back to the
96147932f199be4ad038778e702c13a2f79051c0slive current host, see the <code>[R]</code> flag below.</dd>
96147932f199be4ad038778e702c13a2f79051c0slive
96147932f199be4ad038778e702c13a2f79051c0slive <dt><code>-</code> (dash)</dt>
96147932f199be4ad038778e702c13a2f79051c0slive
96147932f199be4ad038778e702c13a2f79051c0slive <dd>A dash indicates that no substitution should be performed
96147932f199be4ad038778e702c13a2f79051c0slive (the existing path is passed through untouched). This is used
96147932f199be4ad038778e702c13a2f79051c0slive when a flag (see below) needs to be applied without changing
dc585e0df783dd91b8121ea1cfa743cea2ac12fdcovener the path.</dd>
96147932f199be4ad038778e702c13a2f79051c0slive
96147932f199be4ad038778e702c13a2f79051c0slive </dl>
96147932f199be4ad038778e702c13a2f79051c0slive
dbe68b8c92b9bd76e692c045d52820cb55efd6abrbowen <p>In addition to plain text, the <em>Substitution</em> string can include</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <ol>
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin <li>back-references (<code>$N</code>) to the RewriteRule
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive pattern</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin <li>back-references (<code>%N</code>) to the last matched
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive RewriteCond pattern</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>server-variables as in rule condition test-strings
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive (<code>%{VARNAME}</code>)</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li><a href="#mapfunc">mapping-function</a> calls
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive (<code>${mapname:key|default}</code>)</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </ol>
96147932f199be4ad038778e702c13a2f79051c0slive
5f18f92c1354462df6dc2ba38277a953fa700b13gryzor <p>Back-references are identifiers of the form
206b5dce9e48924aa9f12ce87f14856a4cd3fb68takashi <code>$</code><strong>N</strong>
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin (<strong>N</strong>=0..9), which will be replaced
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive by the contents of the <strong>N</strong>th group of the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive matched <em>Pattern</em>. The server-variables are the same
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive as for the <em>TestString</em> of a <code>RewriteCond</code>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive directive. The mapping-functions come from the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>RewriteMap</code> directive and are explained there.
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin These three types of variables are expanded in the order above.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
3bd4f2a469a28a479ba4336e0494802697e67e6arbowen <p>Rewrite rules are applied to the results of previous rewrite
3bd4f2a469a28a479ba4336e0494802697e67e6arbowen rules, in the order in which they are defined
198ed7e689ada03d3236a3d0e709245d2b07dfa2humbedooh in the config file. The URL-path or file-system path (see <a
81fb9d8829c87f498aad9ae764e98d1f60fbfd1crbowen href="#what_is_matched">"What is matched?"</a>, above) is <strong>completely
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive replaced</strong> by the <em>Substitution</em> and the
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin rewriting process continues until all rules have been applied,
81fb9d8829c87f498aad9ae764e98d1f60fbfd1crbowen or it is explicitly terminated by an
3bd4f2a469a28a479ba4336e0494802697e67e6arbowen <a href="/rewrite/flags.html#flag_l"><code><strong>L</strong></code> flag</a>,
3bd4f2a469a28a479ba4336e0494802697e67e6arbowen or other flag which implies immediate termination, such as
3bd4f2a469a28a479ba4336e0494802697e67e6arbowen <code><strong>END</strong></code> or
3bd4f2a469a28a479ba4336e0494802697e67e6arbowen <code><strong>F</strong></code>.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
96147932f199be4ad038778e702c13a2f79051c0slive <note><title>Modifying the Query String</title>
96147932f199be4ad038778e702c13a2f79051c0slive <p>By default, the query string is passed through unchanged. You
96147932f199be4ad038778e702c13a2f79051c0slive can, however, create URLs in the substitution string containing
96147932f199be4ad038778e702c13a2f79051c0slive a query string part. Simply use a question mark inside the
96147932f199be4ad038778e702c13a2f79051c0slive substitution string to indicate that the following text should
96147932f199be4ad038778e702c13a2f79051c0slive be re-injected into the query string. When you want to erase an
96147932f199be4ad038778e702c13a2f79051c0slive existing query string, end the substitution string with just a
96147932f199be4ad038778e702c13a2f79051c0slive question mark. To combine new and old query strings, use the
5f18f92c1354462df6dc2ba38277a953fa700b13gryzor <code>[QSA]</code> flag.</p>
96147932f199be4ad038778e702c13a2f79051c0slive </note>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
21f4ac5ab80abe4cbe90ae0f340c29053556c52drbowen <p>Additionally you can set special <a name="rewriteflags"
5f18f92c1354462df6dc2ba38277a953fa700b13gryzor id="rewriteflags">actions</a> to be performed by
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin appending <strong><code>[</code><em>flags</em><code>]</code></strong>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive as the third argument to the <code>RewriteRule</code>
5f18f92c1354462df6dc2ba38277a953fa700b13gryzor directive. <em>Flags</em> is a comma-separated list, surround by square
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen brackets, of any of the flags in the following table. More
2f44538c88c5310bebb17a39b171487315a45624lgentis details, and examples, for each flag, are available in the <a
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen href="/rewrite/flags.html">Rewrite Flags document</a>.</p>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc <table border="1" style="zebra">
2f44538c88c5310bebb17a39b171487315a45624lgentis <tr><th>Flag and syntax</th>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <th>Function</th>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>B</td>
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coar <td>Escape non-alphanumeric characters in backreferences <em>before</em>
fb3a95a3e216c3d38c381fd1425c19cef5fe87abcovener applying the transformation. <em><a
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen href="/rewrite/flags.html#flag_b">details ...</a></em></td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </tr>
1b988c41ee505962781d110a3e4c2c90f1ea0aa4covener <tr>
1b988c41ee505962781d110a3e4c2c90f1ea0aa4covener <td>backrefnoplus|BNP</td>
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coar <td>If backreferences are being escaped, spaces should be escaped to
1b988c41ee505962781d110a3e4c2c90f1ea0aa4covener %20 instead of +. Useful when the backreference will be used in the
1b988c41ee505962781d110a3e4c2c90f1ea0aa4covener path component rather than the query string.<em><a
1b988c41ee505962781d110a3e4c2c90f1ea0aa4covener href="/rewrite/flags.html#flag_bnp">details ...</a></em></td>
1b988c41ee505962781d110a3e4c2c90f1ea0aa4covener </tr>
1b988c41ee505962781d110a3e4c2c90f1ea0aa4covener
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>chain|C</td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>Rule is chained to the following rule. If the rule fails,
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen the rule(s) chained to it will be skipped. <em><a
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen href="/rewrite/flags.html#flag_c">details ...</a></em></td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>cookie|CO=<em>NAME</em>:<em>VAL</em></td>
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim <td>Sets a cookie in the client browser. Full syntax is:
ab058bbbd467a540b481cb3c6443035e4a39ef48rbowen CO=<em>NAME</em>:<em>VAL</em>:<em>domain</em>[:<em>lifetime</em>[:<em>path</em>[:<em>secure</em>[:<em>httponly</em>]]]] <em><a href="/rewrite/flags.html#flag_co">details ...</a></em>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <tr>
75364a8a894b12c75cb3545c78764a00346db9f9jorton <td>discardpath|DPI</td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>Causes the PATH_INFO portion of the rewritten URI to be
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim discarded. <em><a href="/rewrite/flags.html#flag_dpi">details
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen ...</a></em></td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </tr>
cc253dfdd0c1682d55910b7f085fd6a06d224e80rbowen <tr>
cc253dfdd0c1682d55910b7f085fd6a06d224e80rbowen <td>END</td>
cc253dfdd0c1682d55910b7f085fd6a06d224e80rbowen <td>Stop the rewriting process immediately and don't apply any
cc253dfdd0c1682d55910b7f085fd6a06d224e80rbowen more rules. Also prevents further execution of rewrite rules
cc253dfdd0c1682d55910b7f085fd6a06d224e80rbowen in per-directory and .htaccess context. (Available in 2.3.9 and later)
e3f22cc532d5d8b11560f70e994d6ac281b35b50rbowen <em><a href="/rewrite/flags.html#flag_end">details ...</a></em></td>
cc253dfdd0c1682d55910b7f085fd6a06d224e80rbowen </tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <tr>
12b26f433fd7d6fc9f76413d7c2cabf4fa5cb300sf <td>env|E=[!]<em>VAR</em>[:<em>VAL</em>]</td>
39d67f66729a7008c1e73d65a81e778ce819a227rjung <td>Causes an environment variable <em>VAR</em> to be set (to the
12b26f433fd7d6fc9f76413d7c2cabf4fa5cb300sf value <em>VAL</em> if provided). The form !<em>VAR</em> causes
de2d5641f213f49317857e989e21a86c49f2b96brbowen the environment variable <em>VAR</em> to be unset.
de2d5641f213f49317857e989e21a86c49f2b96brbowen <em><a href="/rewrite/flags.html#flag_e">details ...</a></em></td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>forbidden|F</td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>Returns a 403 FORBIDDEN response to the client browser.
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <em><a href="/rewrite/flags.html#flag_f">details ...</a></em></td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>gone|G</td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>Returns a 410 GONE response to the client browser. <em><a
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen href="/rewrite/flags.html#flag_g">details ...</a></em></td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>Handler|H=<em>Content-handler</em></td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>Causes the resulting URI to be sent to the specified
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <em>Content-handler</em> for processing. <em><a
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen href="/rewrite/flags.html#flag_h">details ...</a></em></td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>last|L</td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>Stop the rewriting process immediately and don't apply any
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen more rules. Especially note caveats for per-directory and
503bec4c591d28ac6cec7182294cdef2ec6a9829covener .htaccess context (see also the END flag). <em><a
e3f22cc532d5d8b11560f70e994d6ac281b35b50rbowen href="/rewrite/flags.html#flag_l">details ...</a></em></td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>next|N</td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>Re-run the rewriting process, starting again with the first
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen rule, using the result of the ruleset so far as a starting
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen point. <em><a href="/rewrite/flags.html#flag_n">details
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen ...</a></em></td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>nocase|NC</td>
9acc64833096d98e78737366e67c31de7a128801rbowen <td>Makes the pattern comparison case-insensitive.
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <em><a href="/rewrite/flags.html#flag_nc">details ...</a></em></td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>noescape|NE</td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>Prevent mod_rewrite from applying hexcode escaping of
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen special characters in the result of the rewrite. <em><a
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen href="/rewrite/flags.html#flag_ne">details ...</a></em></td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>nosubreq|NS</td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>Causes a rule to be skipped if the current request is an
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen internal sub-request. <em><a
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen href="/rewrite/flags.html#flag_ns">details ...</a></em></td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>proxy|P</td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>Force the substitution URL to be internally sent as a proxy
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen request. <em><a href="/rewrite/flags.html#flag_p">details
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen ...</a></em></td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>passthrough|PT</td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>Forces the resulting URI to be passed back to the URL
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen mapping engine for processing of other URI-to-filename
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen translators, such as <code>Alias</code> or
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <code>Redirect</code>. <em><a
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen href="/rewrite/flags.html#flag_pt">details ...</a></em></td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>qsappend|QSA</td>
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coar <td>Appends any query string from the original request URL to
4988bb943ad0c9b851eae6a2e5d9a59529630b96rbowen any query string created in the rewrite target.<em><a
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen href="/rewrite/flags.html#flag_qsa">details ...</a></em></td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>qsdiscard|QSD</td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>Discard any query string attached to the incoming URI.
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <em><a href="/rewrite/flags.html#flag_qsd">details
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen ...</a></em></td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>redirect|R[=<em>code</em>]</td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>Forces an external redirect, optionally with the specified
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen HTTP status code. <em><a
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen href="/rewrite/flags.html#flag_r">details ...</a></em>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>skip|S=<em>num</em></td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>Tells the rewriting engine to skip the next <em>num</em>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen rules if the current rule matches. <em><a
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen href="/rewrite/flags.html#flag_s">details ...</a></em></td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <tr>
4c70a9479f5d5fa75146488cfad5ad6882056446rbowen <td>type|T=<em>MIME-type</em></td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>Force the <glossary>MIME-type</glossary> of the target file
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen to be the specified type. <em><a
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen href="/rewrite/flags.html#flag_t">details ...</a></em></td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </table>
ff21ab9f1cc3037fe58a2029432834581594b6c4pctony
de68ca33425122cf4a880859013e08e84f8143a5covener<note><title>Home directory expansion</title>
de68ca33425122cf4a880859013e08e84f8143a5covener<p> When the substitution string begins with a string
de68ca33425122cf4a880859013e08e84f8143a5covenerresembling "/~user" (via explicit text or backreferences), mod_rewrite performs
5f18f92c1354462df6dc2ba38277a953fa700b13gryzorhome directory expansion independent of the presence or configuration
4e6d765a1b53690664877065e6b6c741c1b96937covenerof <module>mod_userdir</module>.</p>
de68ca33425122cf4a880859013e08e84f8143a5covener
de68ca33425122cf4a880859013e08e84f8143a5covener<p> This expansion does not occur when the <em>PT</em>
de68ca33425122cf4a880859013e08e84f8143a5covenerflag is used on the <directive module="mod_rewrite">RewriteRule</directive>
de68ca33425122cf4a880859013e08e84f8143a5covenerdirective.</p>
de68ca33425122cf4a880859013e08e84f8143a5covener</note>
de68ca33425122cf4a880859013e08e84f8143a5covener
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
b1136023d7083e8ada7ee2a7f8563383568d0e9cnoirin <p>Here are all possible substitution combinations and their
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive meanings:</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p><strong>Inside per-server configuration
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive (<code>httpd.conf</code>)<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive for request ``<code>GET
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive /somepath/pathinfo</code>'':</strong><br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc<table border="1" style="zebra">
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<th>Given Rule</th>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<th>Resulting Substitution</th>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^/somepath(.*) otherpath$1</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>invalid, not supported</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^/somepath(.*) otherpath$1 [R]</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>invalid, not supported</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^/somepath(.*) otherpath$1 [P]</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>invalid, not supported</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^/somepath(.*) /otherpath$1</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>/otherpath/pathinfo</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^/somepath(.*) /otherpath$1 [R]</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>http://thishost/otherpath/pathinfo via external redirection</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^/somepath(.*) /otherpath$1 [P]</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>doesn't make sense, not supported</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^/somepath(.*) http://thishost/otherpath$1</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>/otherpath/pathinfo</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^/somepath(.*) http://thishost/otherpath$1 [R]</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>http://thishost/otherpath/pathinfo via external redirection</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^/somepath(.*) http://thishost/otherpath$1 [P]</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>doesn't make sense, not supported</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^/somepath(.*) http://otherhost/otherpath$1</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>http://otherhost/otherpath/pathinfo via external redirection</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^/somepath(.*) http://otherhost/otherpath$1 [R]</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>http://otherhost/otherpath/pathinfo via external redirection (the [R] flag is redundant)</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^/somepath(.*) http://otherhost/otherpath$1 [P]</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>http://otherhost/otherpath/pathinfo via internal proxy</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</table>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p><strong>Inside per-directory configuration for
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>/somepath</code><br />
8c3a1a087bdee9c6156951ef748adee127ab0bd1humbedooh (<code>/physical/path/to/somepath/.htaccess</code>, with
5d01f40ffd657dd2ac567aacd93cabd162ddfa79coar <code>RewriteBase "/somepath"</code>)<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive for request ``<code>GET
5f18f92c1354462df6dc2ba38277a953fa700b13gryzor /somepath/localpath/pathinfo</code>'':</strong><br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
10e9674fc9606633f493d0e409d2bf143ccac1fejailletc<table border="1" style="zebra">
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<th>Given Rule</th>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<th>Resulting Substitution</th>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^localpath(.*) otherpath$1</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>/somepath/otherpath/pathinfo</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^localpath(.*) otherpath$1 [R]</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>http://thishost/somepath/otherpath/pathinfo via external
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowenredirection</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^localpath(.*) otherpath$1 [P]</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>doesn't make sense, not supported</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^localpath(.*) /otherpath$1</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>/otherpath/pathinfo</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^localpath(.*) /otherpath$1 [R]</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>http://thishost/otherpath/pathinfo via external redirection</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^localpath(.*) /otherpath$1 [P]</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>doesn't make sense, not supported</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^localpath(.*) http://thishost/otherpath$1</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>/otherpath/pathinfo</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^localpath(.*) http://thishost/otherpath$1 [R]</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>http://thishost/otherpath/pathinfo via external redirection</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^localpath(.*) http://thishost/otherpath$1 [P]</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>doesn't make sense, not supported</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^localpath(.*) http://otherhost/otherpath$1</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>http://otherhost/otherpath/pathinfo via external redirection</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^localpath(.*) http://otherhost/otherpath$1 [R]</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>http://otherhost/otherpath/pathinfo via external redirection (the [R] flag is redundant)</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^localpath(.*) http://otherhost/otherpath$1 [P]</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>http://otherhost/otherpath/pathinfo via internal proxy</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</table>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj </usage>
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj </directivesynopsis>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</modulesynopsis>