mod_rewrite.xml revision 162cd8b9fb88668739596f3e2fe8e97a3c98fe22
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<?xml version="1.0"?>
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj<!DOCTYPE modulesynopsis SYSTEM "/style/modulesynopsis.dtd">
e942c741056732f50da2074b36fe59805d370650slive<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
1d7d4ad3081da9e2bc11611ddccdf68f89e8baf9nd<!-- $LastChangedRevision$ -->
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd<!--
6fbd2e53c97ea6976d93e0ac521adabc55e0fb73nd Licensed to the Apache Software Foundation (ASF) under one or more
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd contributor license agreements. See the NOTICE file distributed with
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd this work for additional information regarding copyright ownership.
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd The ASF licenses this file to You under the Apache License, Version 2.0
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd (the "License"); you may not use this file except in compliance with
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd the License. You may obtain a copy of the License at
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd http://www.apache.org/licenses/LICENSE-2.0
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd Unless required by applicable law or agreed to in writing, software
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd distributed under the License is distributed on an "AS IS" BASIS,
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd See the License for the specific language governing permissions and
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd limitations under the License.
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd-->
7db9f691a00ead175b03335457ca296a33ddf31bnd
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<modulesynopsis metafile="mod_rewrite.xml.meta">
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<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>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>The <module>mod_rewrite</module> module uses a rule-based rewriting
97a9a944b5887e91042b019776c41d5dd74557aferikabele engine, based on a PCRE regular-expression parser, to rewrite requested URLs on
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the fly. By default, <module>mod_rewrite</module> maps a URL to a filesystem
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive path. However, it can also be used to redirect one URL to another URL, or
97a9a944b5887e91042b019776c41d5dd74557aferikabele to invoke an internal proxy fetch.</p>
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj <p><module>mod_rewrite</module> provides a flexible and powerful way to
97a9a944b5887e91042b019776c41d5dd74557aferikabele manipulate URLs using an unlimited number of rules. Each rule can have an
97a9a944b5887e91042b019776c41d5dd74557aferikabele unlimited number of attached rule conditions, to allow you to rewrite URL
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive based on server variables, environment variables, HTTP headers, or time
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive stamps.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p><module>mod_rewrite</module> operates on the full URL path, including the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive path-info section. A rewrite rule can be invoked in
97a9a944b5887e91042b019776c41d5dd74557aferikabele <code>httpd.conf</code> or in <code>.htaccess</code>. The path generated
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive by a rewrite rule can include a query string, or can lead to internal
97a9a944b5887e91042b019776c41d5dd74557aferikabele sub-processing, external request redirection, or internal proxy
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj throughput.</p>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
97a9a944b5887e91042b019776c41d5dd74557aferikabele <p>Further details, discussion, and examples, are provided in the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <a href="/rewrite/">detailed mod_rewrite documentation</a>.</p>
97a9a944b5887e91042b019776c41d5dd74557aferikabele</summary>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<section id="logging"><title>Logging</title>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p><module>mod_rewrite</module> offers detailed logging of its actions
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive at the <code>trace1</code> to <code>trace8</code> log levels. The
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive log level can be set specifically for <module>mod_rewrite</module>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive using the <directive module="core">LogLevel</directive> directive: Up to
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive level <code>debug</code>, no actions are logged, while <code>trace8</code>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive means that practically all actions are logged.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <note>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive Using a high trace log level for <module>mod_rewrite</module>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive will slow down your Apache HTTP Server dramatically! Use a log
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive level higher than <code>trace2</code> only for debugging!
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </note>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <example><title>Example</title>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <highlight language="config">
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive LogLevel alert rewrite:trace3
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </highlight>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </example>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <note><title>RewriteLog</title>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>Those familiar with earlier versions of
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <module>mod_rewrite</module> will no doubt be looking for the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>RewriteLog</code> and <code>RewriteLogLevel</code>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive directives. This functionality has been completely replaced by the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive new per-module logging configuration mentioned above.
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>To get just the <module>mod_rewrite</module>-specific log
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive messages, pipe the log file through grep:</p>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <example>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive tail -f error_log|fgrep '[rewrite:'
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </example>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </note>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</section>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele<directivesynopsis>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<name>RewriteEngine</name>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<description>Enables or disables runtime rewriting engine</description>
630c456b6461158be6cc5c5483735e27b13b4ad5nd<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
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<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
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>Use this directive to disable the module instead of
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive commenting out all the <directive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive module="mod_rewrite">RewriteRule</directive> directives!</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>Note that rewrite configurations are not
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive inherited by virtual hosts. This means that you need to have a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>RewriteEngine on</code> directive for each virtual host
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive in which you wish to use rewrite rules.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p><directive>RewriteMap</directive> directives of the type <code>prg</code>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive are not started during server initialization if they're defined in a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive context that does not have <directive>RewriteEngine</directive> set to
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <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>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<syntax>RewriteOptions <var>Options</var></syntax>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<contextlist><context>server config</context><context>virtual host</context>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<context>directory</context><context>.htaccess</context></contextlist>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<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
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive configuration. The <em>Option</em> string can currently
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive only be one of the following:</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dl>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dt><code>Inherit</code></dt>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dd>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>This forces the current configuration to inherit the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive configuration of the parent. In per-virtual-server context,
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive this means that the maps, conditions and rules of the main
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive server are inherited. In per-directory context this means
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive that conditions and rules of the parent directory's
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>.htaccess</code> configuration or
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <directive type="section" module="core">Directory</directive>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive sections are inherited. The inherited rules are virtually copied
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive to the section where this directive is being used. If used in
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive combination with local rules, the inherited rules are copied behind
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the local rules. The position of this directive - below or above
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive of local rules - has no influence on this behavior. If local
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive rules forced the rewriting to stop, the inherited rules won't
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive be processed.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <note type="warning">
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive Rules inherited from the parent scope are applied
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <strong>after</strong> rules specified in the child scope.
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </note>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </dd>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dt><code>InheritBefore</code></dt>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dd>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p> Like <code>Inherit</code> above, but the rules from the parent scope
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive are applied <strong>before</strong> rules specified in the child scope.
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive Available in Apache HTTP Server 2.3.10 and later.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </dd>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dt><code>AllowNoSlash</code></dt>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dd>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>By default, <module>mod_rewrite</module> will ignore URLs that map to a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive directory on disk but lack a trailing slash, in the expectation that
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the <module>mod_dir</module> module will issue the client with a redirect to
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the canonical URL with a trailing slash.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>When the <directive module="mod_dir">DirectorySlash</directive> directive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive is set to off, the <code>AllowNoSlash</code> option can be enabled to ensure
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive that rewrite rules are no longer ignored. This option makes it possible to
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive apply rewrite rules within .htaccess files that match the directory without
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive a trailing slash, if so desired. Available in Apache HTTP Server 2.4.0 and
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive later.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </dd>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dt><code>AllowAnyURI</code></dt>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dd>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>When <directive module="mod_rewrite">RewriteRule</directive>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive is used in <code>VirtualHost</code> or server context with
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive version 2.2.22 or later of httpd, <module>mod_rewrite</module>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive will only process the rewrite rules if the request URI is a <a
97a9a944b5887e91042b019776c41d5dd74557aferikabele href="/directive-dict.html#Syntax">URL-path</a>. This avoids
97a9a944b5887e91042b019776c41d5dd74557aferikabele some security issues where particular rules could allow
97a9a944b5887e91042b019776c41d5dd74557aferikabele "surprising" pattern expansions (see <a
97a9a944b5887e91042b019776c41d5dd74557aferikabele href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-3368">CVE-2011-3368</a>
97a9a944b5887e91042b019776c41d5dd74557aferikabele and <a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-4317">CVE-2011-4317</a>).
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive To lift the restriction on matching a URL-path, the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>AllowAnyURI</code> option can be enabled, and
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <module>mod_rewrite</module> will apply the rule set to any
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive request URI string, regardless of whether that string matches
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the URL-path grammar required by the HTTP specification.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <note type="warning">
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <title>Security Warning</title>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>Enabling this option will make the server vulnerable to
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive security issues if used with rewrite rules which are not
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive carefully authored. It is <strong>strongly recommended</strong>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive that this option is not used. In particular, beware of input
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive strings containing the '<code>@</code>' character which could
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive change the interpretation of the transformed URI, as per the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive above CVE names.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </note>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </dd>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dt><code>MergeBase</code></dt>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dd>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>With this option, the value of <directive module="mod_rewrite"
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive >RewriteBase</directive> is copied from where it's explicitly defined
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive into any sub-directory or sub-location that doesn't define its own
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj <directive module="mod_rewrite">RewriteBase</directive>. Available in
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive Apache HTTP Server 2.5 and later only.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </dd>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </dl>
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj
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>
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
97a9a944b5887e91042b019776c41d5dd74557aferikabele substitution strings by the mapping-functions to
97a9a944b5887e91042b019776c41d5dd74557aferikabele insert/substitute fields through a key lookup. The source of
97a9a944b5887e91042b019776c41d5dd74557aferikabele this lookup can be of various types.</p>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
97a9a944b5887e91042b019776c41d5dd74557aferikabele <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
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <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>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <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
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive if no <em>DefaultValue</em> was specified. Empty values
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive behave as if the key was absent, therefore it is not possible
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive to distinguish between empty-valued keys and absent keys.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>For example, you might define a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <directive>RewriteMap</directive> as:</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele <highlight language="config">
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive RewriteMap examplemap txt:/path/to/file/map.txt
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </highlight>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>You would then be able to use this map in a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <directive>RewriteRule</directive> as follows:</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <highlight language="config">
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive RewriteRule ^/ex/(.*) ${examplemap:$1}
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </highlight>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>The following combinations for <em>MapType</em> and
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em>MapSource</em> can be used:</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dl>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dt>txt</dt>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dd>A plain text file containing space-separated key-value
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive pairs, one per line. (<a href="/rewrite/rewritemap.html#txt">Details ...</a>)</dd>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dt>rnd</dt>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dd>Randomly selects an entry from a plain text file (<a href="/rewrite/rewritemap.html#rnd">Details ...</a>)</dd>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj <dt>dbm</dt>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dd>Looks up an entry in a dbm file containing name, value
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive pairs. Hash is constructed from a plain text file format using
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the <code><a href="/programs/httxt2dbm.html">httxt2dbm</a></code>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive utility. (<a href="/rewrite/rewritemap.html#dbm">Details ...</a>)</dd>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dt>int</dt>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dd>One of the four available internal functions provided by
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>RewriteMap</code>: toupper, tolower, escape or
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive unescape. (<a href="/rewrite/rewritemap.html#int">Details ...</a>)</dd>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dt>prg</dt>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dd>Calls an external program or script to process the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive rewriting. (<a href="/rewrite/rewritemap.html#prg">Details ...</a>)</dd>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dt>dbd or fastdbd</dt>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dd>A SQL SELECT statement to be performed to look up the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive rewrite target. (<a href="/rewrite/rewritemap.html#dbd">Details ...</a>)</dd>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </dl>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>Further details, and numerous examples, may be found in the <a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive 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>
9ed9ba1fcf0a4a39f78f5f809c661bbd590b70eand<default>None</default>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<contextlist><context>directory</context><context>.htaccess</context>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</contextlist>
630c456b6461158be6cc5c5483735e27b13b4ad5nd<override>FileInfo</override>
1d7d4ad3081da9e2bc11611ddccdf68f89e8baf9nd
9ed9ba1fcf0a4a39f78f5f809c661bbd590b70eand<usage>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>The <directive>RewriteBase</directive> directive specifies the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive URL prefix to be used for per-directory (htaccess)
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <directive>RewriteRule</directive> directives that substitute a relative
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive path.</p>
1d7d4ad3081da9e2bc11611ddccdf68f89e8baf9nd <p> This directive is <em>required</em> when you use a relative path
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive in a substitution in per-directory (htaccess) context unless either
9ed9ba1fcf0a4a39f78f5f809c661bbd590b70eand of the following conditions are true:</p>
9ed9ba1fcf0a4a39f78f5f809c661bbd590b70eand <ul>
9ed9ba1fcf0a4a39f78f5f809c661bbd590b70eand <li> The original request, and the substitution, are underneath the
9ed9ba1fcf0a4a39f78f5f809c661bbd590b70eand <directive module="core">DocumentRoot</directive>
9ed9ba1fcf0a4a39f78f5f809c661bbd590b70eand (as opposed to reachable by other means, such as
9ed9ba1fcf0a4a39f78f5f809c661bbd590b70eand <directive module="mod_alias">Alias</directive>).</li>
9ed9ba1fcf0a4a39f78f5f809c661bbd590b70eand <li> The <em>filesystem</em> path to the directory containing the
9ed9ba1fcf0a4a39f78f5f809c661bbd590b70eand <directive>RewriteRule</directive>, suffixed by the relative
9ed9ba1fcf0a4a39f78f5f809c661bbd590b70eand substitution is also valid as a URL path on the server
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive (this is rare).</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </ul>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<p> In the example below, <directive>RewriteBase</directive> is necessary
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive to avoid rewriting to http://example.com/opt/myapp-1.2.3/welcome.html
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive since the resource was not relative to the document root. This
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive misconfiguration would normally cause the server to look for an "opt"
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive directory under the document root.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<highlight language="config">
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfsliveDocumentRoot /var/www/example.com
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfsliveAlias /myapp /opt/myapp-1.2.3
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive&lt;Directory /opt/myapp-1.2.3&gt;
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive RewriteEngine On
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive RewriteBase /myapp/
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive RewriteRule ^index\.html$ welcome.html
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive&lt;/Directory&gt;
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</highlight>
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
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj<usage>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>The <directive>RewriteCond</directive> directive defines a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive rule condition. One or more <directive>RewriteCond</directive>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive can precede a <directive module="mod_rewrite">RewriteRule</directive>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive directive. The following rule is then only used if both
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the current state of the URI matches its pattern, <strong
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive >and</strong> if these conditions are met.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p><em>TestString</em> is a string which can contain the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive following expanded constructs in addition to plain text:</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <ul>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <strong>RewriteRule backreferences</strong>: These are
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive backreferences of the form <strong><code>$N</code></strong>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive (0 &lt;= N &lt;= 9). $1 to $9 provide access to the grouped
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive parts (in parentheses) of the pattern, from the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>RewriteRule</code> which is subject to the current
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive set of <code>RewriteCond</code> conditions. $0 provides
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive access to the whole string matched by that pattern.
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </li>
382bd1f7cfdb0fc3df6f31c6082f729b3ceb6e66erikabele <li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <strong>RewriteCond backreferences</strong>: These are
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive backreferences of the form <strong><code>%N</code></strong>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive (0 &lt;= N &lt;= 9). %1 to %9 provide access to the grouped
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive parts (again, in parentheses) of the pattern, from the last matched
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>RewriteCond</code> in the current set
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive of conditions. %0 provides access to the whole string matched by
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive that pattern.
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <strong>RewriteMap expansions</strong>: These are
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive expansions of the form <strong><code
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive >${mapname:key|default}</code></strong>.
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive See <a href="#mapfunc">the documentation for
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive RewriteMap</a> for more details.
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <strong>Server-Variables</strong>: These are variables of
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the form
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <strong><code>%{</code> <em>NAME_OF_VARIABLE</em>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>}</code></strong>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive where <em>NAME_OF_VARIABLE</em> can be a string taken
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive from the following list:
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <table>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <columnspec><column width=".3"/><column width=".3"/>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <column width=".3"/></columnspec>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <th>HTTP headers:</th> <th>connection &amp; request:</th> <th></th>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive HTTP_USER_AGENT<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive HTTP_REFERER<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive HTTP_COOKIE<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive HTTP_FORWARDED<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive HTTP_HOST<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive HTTP_PROXY_CONNECTION<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive HTTP_ACCEPT<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive REMOTE_ADDR<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive REMOTE_HOST<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive REMOTE_PORT<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive REMOTE_USER<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive REMOTE_IDENT<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive REQUEST_METHOD<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive SCRIPT_FILENAME<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive PATH_INFO<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive QUERY_STRING<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive AUTH_TYPE<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
630c456b6461158be6cc5c5483735e27b13b4ad5nd <td></td>
630c456b6461158be6cc5c5483735e27b13b4ad5nd </tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <th>server internals:</th> <th>date and time:</th> <th>specials:</th>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive DOCUMENT_ROOT<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive SERVER_ADMIN<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive SERVER_NAME<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive SERVER_ADDR<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive SERVER_PORT<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive SERVER_PROTOCOL<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele SERVER_SOFTWARE<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive TIME_YEAR<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive TIME_MON<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele 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
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive API_VERSION<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive THE_REQUEST<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive REQUEST_URI<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive REQUEST_FILENAME<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive IS_SUBREQ<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive HTTPS<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive REQUEST_SCHEME<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </table>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>These variables all
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive correspond to the similarly named HTTP
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive MIME-headers, C variables of the Apache HTTP Server or
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>struct tm</code> fields of the Unix system.
97a9a944b5887e91042b019776c41d5dd74557aferikabele Most are documented elsewhere in the Manual or in
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the CGI specification.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele <p>SERVER_NAME and SERVER_PORT depend on the values of
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <directive module="core">UseCanonicalName</directive> and
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <directive module="core">UseCanonicalPhysicalPort</directive>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive respectively.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>Those that are special to mod_rewrite include those below.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <note>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dl>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dt><code>IS_SUBREQ</code></dt>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dd>Will contain the text "true" if the request
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive currently being processed is a sub-request,
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive "false" otherwise. Sub-requests may be generated
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive by modules that need to resolve additional files
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive or URIs in order to complete their tasks.</dd>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dt><code>API_VERSION</code></dt>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dd>This is the version of the Apache httpd module API
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive (the internal interface between server and
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive module) in the current httpd build, as defined in
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive include/ap_mmn.h. The module API version
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive corresponds to the version of Apache httpd in use (in
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the release version of Apache httpd 1.3.14, for
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive instance, it is 19990320:10), but is mainly of
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive interest to module authors.</dd>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dt><code>THE_REQUEST</code></dt>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dd>The full HTTP request line sent by the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive browser to the server (e.g., "<code>GET
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive /index.html HTTP/1.1</code>"). This does not
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive include any additional headers sent by the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive browser. This value has not been unescaped
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive (decoded), unlike most other variables below.</dd>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dt><code>REQUEST_URI</code></dt>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dd>The path component of the requested URI,
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive such as "/index.html". This notably excludes the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive query string which is available as as its own variable
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive named <code>QUERY_STRING</code>.</dd>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dt><code>REQUEST_FILENAME</code></dt>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dd>The full local filesystem path to the file or
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive script matching the request, if this has already
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive been determined by the server at the time
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>REQUEST_FILENAME</code> is referenced. Otherwise,
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive such as when used in virtual host context, the same
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive value as <code>REQUEST_URI</code>.</dd>
1578daeec017d3bb20cecdcdc3b0261c999730d5slive
1578daeec017d3bb20cecdcdc3b0261c999730d5slive <dt><code>HTTPS</code></dt>
1578daeec017d3bb20cecdcdc3b0261c999730d5slive
1578daeec017d3bb20cecdcdc3b0261c999730d5slive <dd>Will contain the text "on" if the connection is
1578daeec017d3bb20cecdcdc3b0261c999730d5slive using SSL/TLS, or "off" otherwise. (This variable
1578daeec017d3bb20cecdcdc3b0261c999730d5slive can be safely used regardless of whether or not
1578daeec017d3bb20cecdcdc3b0261c999730d5slive <module>mod_ssl</module> is loaded).</dd>
1578daeec017d3bb20cecdcdc3b0261c999730d5slive
1578daeec017d3bb20cecdcdc3b0261c999730d5slive <dt><code>REQUEST_SCHEME</code></dt>
da5f6dcbdddd73ce8ff7f1327339b0a00ff2ab3amartin
1578daeec017d3bb20cecdcdc3b0261c999730d5slive <dd>Will contain the scheme of the request (usually
1578daeec017d3bb20cecdcdc3b0261c999730d5slive "http" or "https"). This value can be influenced with
1578daeec017d3bb20cecdcdc3b0261c999730d5slive <directive module="core">ServerName</directive>.</dd>
1578daeec017d3bb20cecdcdc3b0261c999730d5slive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </dl>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</note>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </ul>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>If the <em>TestString</em> has the special value <code>expr</code>,
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the <em>CondPattern</em> will be treated as an
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <a href="/expr.html">ap_expr</a>. HTTP headers referenced in the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive expression will be added to the Vary header if the <code>novary</code>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive flag is not given.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>Other things you should be aware of:</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <ol>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <li>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <p>The variables SCRIPT_FILENAME and REQUEST_FILENAME
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive contain the same value - the value of the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>filename</code> field of the internal
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>request_rec</code> structure of the Apache HTTP Server.
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive The first name is the commonly known CGI variable name
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive while the second is the appropriate counterpart of
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive REQUEST_URI (which contains the value of the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>uri</code> field of <code>request_rec</code>).</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>If a substitution occurred and the rewriting continues,
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the value of both variables will be updated accordingly.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>If used in per-server context (<em>i.e.</em>, before the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive request is mapped to the filesystem) SCRIPT_FILENAME and
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive REQUEST_FILENAME cannot contain the full local filesystem
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive path since the path is unknown at this stage of processing.
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive Both variables will initially contain the value of REQUEST_URI
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive in that case. In order to obtain the full local filesystem
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive path of the request in per-server context, use an URL-based
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive look-ahead <code>%{LA-U:REQUEST_FILENAME}</code> to determine
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the final value of REQUEST_FILENAME.</p></li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>%{ENV:variable}</code>, where <em>variable</em> can be
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive any environment variable, is also available.
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive This is looked-up via internal
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive Apache httpd structures and (if not found there) via
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>getenv()</code> from the Apache httpd server process.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>%{SSL:variable}</code>, where <em>variable</em> is the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive name of an <a href="mod_ssl.html#envvars">SSL environment
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive variable</a>, can be used whether or not
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <module>mod_ssl</module> is loaded, but will always expand to
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the empty string if it is not. Example:
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>%{SSL:SSL_CIPHER_USEKEYSIZE}</code> may expand to
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>128</code>.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>%{HTTP:header}</code>, where <em>header</em> can be
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive any HTTP MIME-header name, can always be used to obtain the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive value of a header sent in the HTTP request.
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive Example: <code>%{HTTP:Proxy-Connection}</code> is
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the value of the HTTP header
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive ``<code>Proxy-Connection:</code>''.
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>If a HTTP header is used in a condition this header is added to
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the Vary header of the response in case the condition evaluates to
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive to true for the request. It is <strong>not</strong> added if the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive condition evaluates to false for the request. Adding the HTTP header
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive to the Vary header of the response is needed for proper caching.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>It has to be kept in mind that conditions follow a short circuit
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive logic in the case of the '<strong><code>ornext|OR</code></strong>' flag
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive so that certain conditions might not be evaluated at all.</p></li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>%{LA-U:variable}</code> can be used for look-aheads which perform
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive an internal (URL-based) sub-request to determine the final
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive value of <em>variable</em>. This can be used to access
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive variable for rewriting which is not available at the current
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive stage, but will be set in a later phase.
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>For instance, to rewrite according to the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>REMOTE_USER</code> variable from within the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive per-server context (<code>httpd.conf</code> file) you must
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive use <code>%{LA-U:REMOTE_USER}</code> - this
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive variable is set by the authorization phases, which come
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em>after</em> the URL translation phase (during which mod_rewrite
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive operates).</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>On the other hand, because mod_rewrite implements
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive its per-directory context (<code>.htaccess</code> file) via
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the Fixup phase of the API and because the authorization
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive phases come <em>before</em> this phase, you just can use
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>%{REMOTE_USER}</code> in that context.</p></li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>%{LA-F:variable}</code> can be used to perform an internal
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive (filename-based) sub-request, to determine the final value
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive of <em>variable</em>. Most of the time, this is the same as
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive LA-U above.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </ol>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p><em>CondPattern</em> is the condition pattern,
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive a regular expression which is applied to the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive current instance of the <em>TestString</em>.
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em>TestString</em> is first evaluated, before being matched against
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em>CondPattern</em>.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p><em>CondPattern</em> is usually a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em>perl compatible regular expression</em>, but there is
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive additional syntax available to perform other useful tests against
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the <em>Teststring</em>:</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <ol>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>You can prefix the pattern string with a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive '<code>!</code>' character (exclamation mark) to specify a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <strong>non</strong>-matching pattern.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive You can perform lexicographical string comparisons:
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <ul>
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj <li>'<strong>&lt;CondPattern</strong>' (lexicographically
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive precedes)<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive Treats the <em>CondPattern</em> as a plain string and
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive compares it lexicographically to <em>TestString</em>. True if
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em>TestString</em> lexicographically precedes
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj <em>CondPattern</em>.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>'<strong>&gt;CondPattern</strong>' (lexicographically
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive follows)<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive Treats the <em>CondPattern</em> as a plain string and
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive compares it lexicographically to <em>TestString</em>. True if
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em>TestString</em> lexicographically follows
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em>CondPattern</em>.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>'<strong>=CondPattern</strong>' (lexicographically
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive equal)<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive Treats the <em>CondPattern</em> as a plain string and
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive compares it lexicographically to <em>TestString</em>. True if
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em>TestString</em> is lexicographically equal to
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em>CondPattern</em> (the two strings are exactly
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive equal, character for character). If <em>CondPattern</em>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive is <code>""</code> (two quotation marks) this
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj compares <em>TestString</em> to the empty string.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>'<strong>&lt;=CondPattern</strong>' (lexicographically
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive less than or equal to)<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive Treats the <em>CondPattern</em> as a plain string and
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive compares it lexicographically to <em>TestString</em>. True
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive if <em>TestString</em> lexicographically precedes
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em>CondPattern</em>, or is equal to <em>CondPattern</em>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive (the two strings are equal, character for character).</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>'<strong>&gt;=CondPattern</strong>' (lexicographically
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive greater than or equal to)<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive Treats the <em>CondPattern</em> as a plain string and
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive compares it lexicographically to <em>TestString</em>. True
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj if <em>TestString</em> lexicographically follows
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em>CondPattern</em>, or is equal to <em>CondPattern</em>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive (the two strings are equal, character for character).</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </ul></li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive You can perform integer comparisons:
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <ul>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>'<strong>-eq</strong>' (is numerically
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <strong>eq</strong>ual to)<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive The <em>TestString</em> is treated as an integer, and is
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive numerically compared to the <em>CondPattern</em>. True if
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the two are numerically equal.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>'<strong>-ge</strong>' (is numerically
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <strong>g</strong>reater than or <strong>e</strong>qual to)<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive The <em>TestString</em> is treated as an integer, and is
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive numerically compared to the <em>CondPattern</em>. True if
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the <em>TestString</em> is numerically greater than or equal
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive to the <em>CondPattern</em>.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>'<strong>-gt</strong>' (is numerically
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <strong>g</strong>reater <strong>t</strong>han)<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive The <em>TestString</em> is treated as an integer, and is
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive numerically compared to the <em>CondPattern</em>. True if
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the <em>TestString</em> is numerically greater than
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the <em>CondPattern</em>.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>'<strong>-le</strong>' (is numerically
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <strong>l</strong>ess than or <strong>e</strong>qual to)<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive The <em>TestString</em> is treated as an integer, and is
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive numerically compared to the <em>CondPattern</em>. True if
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the <em>TestString</em> is numerically less than or equal
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive to the <em>CondPattern</em>. Avoid confusion with the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <strong>-l</strong> by using the <strong>-L</strong> or
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <strong>-h</strong> variant.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>'<strong>-lt</strong>' (is numerically
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <strong>l</strong>ess <strong>t</strong>han)<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive The <em>TestString</em> is treated as an integer, and is
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive numerically compared to the <em>CondPattern</em>. True if
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the <em>TestString</em> is numerically less than
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the <em>CondPattern</em>. Avoid confusion with the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <strong>-l</strong> by using the <strong>-L</strong> or
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <strong>-h</strong> variant.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </ul>
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj </li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>You can perform various file attribute tests:
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <ul>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>'<strong>-d</strong>' (is
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <strong>d</strong>irectory)<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive Treats the <em>TestString</em> as a pathname and tests
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive 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
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj whether or not it exists, and is a regular file.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>'<strong>-F</strong>' (is existing file, via
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive subrequest)<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive 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
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive subrequest to do the check, so use it with care -
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive it can impact your server's performance!</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj <li>'<strong>-H</strong>' (is symbolic link, bash convention)<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive See <strong>-l</strong>.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>'<strong>-l</strong>' (is symbolic
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <strong>l</strong>ink)<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive Treats the <em>TestString</em> as a pathname and tests
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive whether or not it exists, and is a symbolic link. May also
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive use the bash convention of <strong>-L</strong> or
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <strong>-h</strong> if there's a possibility of confusion
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive such as when using the <strong>-lt</strong> or
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <strong>-le</strong> tests.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>'<strong>-L</strong>' (is symbolic link, bash convention)<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive See <strong>-l</strong>.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>'<strong>-s</strong>' (is regular file, with
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <strong>s</strong>ize)<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive Treats the <em>TestString</em> as a pathname and tests
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive whether or not it exists, and is a regular file with size greater
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive than zero.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>'<strong>-U</strong>' (is existing URL, via
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive subrequest)<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive 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
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive subrequest to do the check, so use it with care -
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive it can impact your server's performance!</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>'<strong>-x</strong>' (has e<strong>x</strong>ecutable
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive permissions)<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive Treats the <em>TestString</em> as a pathname and tests
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive whether or not it exists, and has executable permissions.
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive These permissions are determined according to
97a9a944b5887e91042b019776c41d5dd74557aferikabele the underlying OS.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele </ul>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<note><title>Note:</title>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive All of these tests can
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive also be prefixed by an exclamation mark ('!') to
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive negate their meaning.
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</note>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>If the <em>TestString</em> has the special value <code>expr</code>, the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em>CondPattern</em> will be treated as an
97a9a944b5887e91042b019776c41d5dd74557aferikabele <a href="/expr.html">ap_expr</a>.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele <p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive In the below example, <code>-strmatch</code> is used to
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive compare the <code>REFERER</code> against the site hostname,
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive to block unwanted hotlinking.
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <highlight language="config">
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive RewriteCond expr "! %{HTTP_REFERER} -strmatch '*://%{HTTP_HOST}/*'"<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive RewriteRule ^/images - [F]
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </highlight>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </li>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>You can also set special flags for
97a9a944b5887e91042b019776c41d5dd74557aferikabele <em>CondPattern</em> by appending
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <strong><code>[</code><em>flags</em><code>]</code></strong>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive as the third argument to the <code>RewriteCond</code>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive directive, where <em>flags</em> is a comma-separated list of any of the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive following flags:
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <ul>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>'<strong><code>nocase|NC</code></strong>'
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive (<strong>n</strong>o <strong>c</strong>ase)<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele This makes the test case-insensitive - differences
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive between 'A-Z' and 'a-z' are ignored, both in the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive expanded <em>TestString</em> and the <em>CondPattern</em>.
97a9a944b5887e91042b019776c41d5dd74557aferikabele 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
97a9a944b5887e91042b019776c41d5dd74557aferikabele <li>
1597043cec6ad37fa4154bf09b0fccdabed1a239slive '<strong><code>ornext|OR</code></strong>'
1597043cec6ad37fa4154bf09b0fccdabed1a239slive (<strong>or</strong> next condition)<br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive Use this to combine rule conditions with a local OR
97a9a944b5887e91042b019776c41d5dd74557aferikabele instead of the implicit AND. Typical example:
97a9a944b5887e91042b019776c41d5dd74557aferikabele
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<highlight language="config">
97a9a944b5887e91042b019776c41d5dd74557aferikabeleRewriteCond %{REMOTE_HOST} ^host1 [OR]
97a9a944b5887e91042b019776c41d5dd74557aferikabeleRewriteCond %{REMOTE_HOST} ^host2 [OR]
97a9a944b5887e91042b019776c41d5dd74557aferikabeleRewriteCond %{REMOTE_HOST} ^host3
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfsliveRewriteRule ...some special stuff for any of these hosts...
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</highlight>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive Without this flag you would have to write the condition/rule
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive pair three times.
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>'<strong><code>novary|NV</code></strong>'
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj (<strong>n</strong>o <strong>v</strong>ary)<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele If a HTTP header is used in the condition, this flag prevents
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive this header from being added to the Vary header of the response. <br />
74a6de79356cd15d2e47065087785e36dd65aa41nd Using this flag might break proper caching of the response if
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the representation of this response varies on the value of this header.
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive So this flag should be only used if the meaning of the Vary header
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive is well understood.
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </ul>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </ol>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele <p><strong>Example:</strong></p>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
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>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
97a9a944b5887e91042b019776c41d5dd74557aferikabele<highlight language="config">
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfsliveRewriteCond %{HTTP_USER_AGENT} ^Mozilla
97a9a944b5887e91042b019776c41d5dd74557aferikabeleRewriteRule ^/$ /homepage.max.html [L]
97a9a944b5887e91042b019776c41d5dd74557aferikabele
97a9a944b5887e91042b019776c41d5dd74557aferikabeleRewriteCond %{HTTP_USER_AGENT} ^Lynx
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfsliveRewriteRule ^/$ /homepage.min.html [L]
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfsliveRewriteRule ^/$ /homepage.std.html [L]
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</highlight>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>Explanation: If you use a browser which identifies itself
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive as 'Mozilla' (including Netscape Navigator, Mozilla etc), then you
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive get the max homepage (which could include frames, or other special
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj features).
97a9a944b5887e91042b019776c41d5dd74557aferikabele If you use the Lynx browser (which is terminal-based), then
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive you get the min homepage (which could be a version designed for
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive easy, text-only browsing).
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive If neither of these conditions apply (you use any other browser,
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive or your browser identifies itself as something non-standard), you get
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the std (standard) homepage.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</usage>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</directivesynopsis>
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj
97a9a944b5887e91042b019776c41d5dd74557aferikabele<directivesynopsis>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<name>RewriteRule</name>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<description>Defines rules for the rewriting engine</description>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<syntax>RewriteRule
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em>Pattern</em> <em>Substitution</em> [<em>flags</em>]</syntax>
fb82af0f0cd7b58eef19c54b086131b7e1e1e749madhum<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
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive rewriting workhorse. The directive can occur more than once,
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive with each instance defining a single rewrite rule. The
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive order in which these rules are defined is important - this is the order
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive in which they will be applied at run-time.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p><a id="patterns" name="patterns"><em>Pattern</em></a> is
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive a perl compatible <a id="regexp" name="regexp">regular
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive expression</a>. On the first RewriteRule, it is matched against
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the (%-decoded) <a href="/directive-dict.html#Syntax">URL-path</a> (or
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <a href="/directive-dict.html#Syntax">file-path</a>, depending
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive on the context) of the request. Subsequent patterns are matched against the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive output of the last matching RewriteRule.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<note><title><a id="what_is_matched" name="what_is_matched">What is matched?</a></title>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>In <directive module="core">VirtualHost</directive> context,
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive The <em>Pattern</em> will initially be matched against the part of the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive URL after the hostname and port, and before the query string (e.g. "/app1/index.html").</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>In <directive module="core">Directory</directive> and htaccess context,
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the <em>Pattern</em> will initially be matched against the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em>filesystem</em> path, after removing the prefix that led the server
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive to the current <directive>RewriteRule</directive> (e.g. "app1/index.html"
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive or "index.html" depending on where the directives are defined).</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>If you wish to match against the hostname, port, or query string, use a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <directive module="mod_rewrite">RewriteCond</directive> with the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>%{HTTP_HOST}</code>, <code>%{SERVER_PORT}</code>, or
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>%{QUERY_STRING}</code> variables respectively.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</note>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<note><title>Per-directory Rewrites</title>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<ul>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<li>The rewrite engine may be used in <a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslivehref="/howto/htaccess.html">.htaccess</a> files and in <directive type="section"
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslivemodule="core">Directory</directive> sections, with some additional
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslivecomplexity.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<li>To enable the rewrite engine in this context, you need to set
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive"<code>RewriteEngine On</code>" <strong>and</strong>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive"<code>Options FollowSymLinks</code>" must be enabled. If your
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfsliveadministrator has disabled override of <code>FollowSymLinks</code> for
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslivea user's directory, then you cannot use the rewrite engine. This
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfsliverestriction is required for security reasons.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<li>When using the rewrite engine in <code>.htaccess</code> files the
7748a5c411233f9e1f3df10ea5fffffa91e58824jortonper-directory prefix (which always is the same for a specific
7748a5c411233f9e1f3df10ea5fffffa91e58824jortondirectory) is automatically <em>removed</em> for the RewriteRule pattern matching
7748a5c411233f9e1f3df10ea5fffffa91e58824jortonand automatically <em>added</em> after any relative (not starting with a
7748a5c411233f9e1f3df10ea5fffffa91e58824jortonslash or protocol name) substitution encounters the end of a rule set.
7748a5c411233f9e1f3df10ea5fffffa91e58824jortonSee the <directive module="mod_rewrite">RewriteBase</directive>
7748a5c411233f9e1f3df10ea5fffffa91e58824jortondirective for more information regarding what prefix will be added back to
7748a5c411233f9e1f3df10ea5fffffa91e58824jortonrelative substitutions.</li>
7748a5c411233f9e1f3df10ea5fffffa91e58824jorton
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<li> If you wish to match against the full URL-path in a per-directory
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive(htaccess) RewriteRule, use the <code>%{REQUEST_URI}</code> variable in
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslivea <directive>RewriteCond</directive>.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<li>The removed prefix always ends with a slash, meaning the matching occurs against a string which
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<em>never</em> has a leading slash. Therefore, a <em>Pattern</em> with <code>^/</code> never
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslivematches in per-directory context.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<li>Although rewrite rules are syntactically permitted in <directive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslivetype="section" module="core">Location</directive> and <directive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslivetype="section" module="core">Files</directive> sections, this
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfsliveshould never be necessary and is unsupported.</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</ul>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</note>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>For some hints on <glossary ref="regex">regular
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive expressions</glossary>, see
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the <a href="/rewrite/intro.html#regex">mod_rewrite
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive Introduction</a>.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>In mod_rewrite, the NOT character
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive ('<code>!</code>') is also available as a possible pattern
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive prefix. This enables you to negate a pattern; to say, for instance:
7748a5c411233f9e1f3df10ea5fffffa91e58824jorton ``<em>if the current URL does <strong>NOT</strong> match this
7748a5c411233f9e1f3df10ea5fffffa91e58824jorton pattern</em>''. This can be used for exceptional cases, where
7748a5c411233f9e1f3df10ea5fffffa91e58824jorton it is easier to match the negative pattern, or as a last
7748a5c411233f9e1f3df10ea5fffffa91e58824jorton default rule.</p>
7748a5c411233f9e1f3df10ea5fffffa91e58824jorton
7748a5c411233f9e1f3df10ea5fffffa91e58824jorton<note><title>Note</title>
7748a5c411233f9e1f3df10ea5fffffa91e58824jortonWhen using the NOT character to negate a pattern, you cannot include
7748a5c411233f9e1f3df10ea5fffffa91e58824jortongrouped wildcard parts in that pattern. This is because, when the
fb82af0f0cd7b58eef19c54b086131b7e1e1e749madhumpattern does NOT match (ie, the negation matches), there are no
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslivecontents for the groups. Thus, if negated patterns are used, you
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslivecannot use <code>$N</code> in the substitution string!
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</note>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>The <a id="rhs" name="rhs"><em>Substitution</em></a> of a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive rewrite rule is the string that replaces the original URL-path that
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive was matched by <em>Pattern</em>. The <em>Substitution</em> may
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive be a:</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dl>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dt>file-system path</dt>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dd>Designates the location on the file-system of the resource
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive to be delivered to the client. Substitutions are only
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive treated as a file-system path when the rule is configured in
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive server (virtualhost) context and the first component of the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive path in the substitution exists in the file-system</dd>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dt>URL-path</dt>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dd>A <directive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive module="core">DocumentRoot</directive>-relative path to the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive resource to be served. Note that <module>mod_rewrite</module>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive tries to guess whether you have specified a file-system path
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive or a URL-path by checking to see if the first segment of the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive path exists at the root of the file-system. For example, if
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive you specify a <em>Substitution</em> string of
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>/www/file.html</code>, then this will be treated as a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive URL-path <em>unless</em> a directory named <code>www</code>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive exists at the root or your file-system (or, in the case of
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive using rewrites in a <code>.htaccess</code> file, relative to
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive your document root), in which case it will
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive be treated as a file-system path. If you wish other
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive URL-mapping directives (such as <directive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive module="mod_alias">Alias</directive>) to be applied to the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive resulting URL-path, use the <code>[PT]</code> flag as
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive described below.</dd>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
630c456b6461158be6cc5c5483735e27b13b4ad5nd <dt>Absolute URL</dt>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dd>If an absolute URL is specified,
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <module>mod_rewrite</module> checks to see whether the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive hostname matches the current host. If it does, the scheme and
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive hostname are stripped out and the resulting path is treated as
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive a URL-path. Otherwise, an external redirect is performed for
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the given URL. To force an external redirect back to the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive current host, see the <code>[R]</code> flag below.</dd>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dt><code>-</code> (dash)</dt>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <dd>A dash indicates that no substitution should be performed
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive (the existing path is passed through untouched). This is used
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive when a flag (see below) needs to be applied without changing
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the path.</dd>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </dl>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>In addition to plain text, the <em>Substitution</em> string can include</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <ol>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <li>back-references (<code>$N</code>) to the RewriteRule
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive pattern</li>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <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>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj <p>Back-references are identifiers of the form
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>$</code><strong>N</strong>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive (<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.
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive These three types of variables are expanded in the order above.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>Rewrite rules are applied to the results of previous rewrite
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive rules, in the order in which they are defined
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive in the config file. The URL-path or file-system path (see <a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive href="#what_is_matched">"What is matched?"</a>, above) is <strong>completely
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive replaced</strong> by the <em>Substitution</em> and the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive rewriting process continues until all rules have been applied,
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive or it is explicitly terminated by an
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <a href="/rewrite/flags.html#flag_l"><code><strong>L</strong></code> flag</a>,
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive or other flag which implies immediate termination, such as
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code><strong>END</strong></code> or
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code><strong>F</strong></code>.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <note><title>Modifying the Query String</title>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>By default, the query string is passed through unchanged. You
4e3cdb85620921a8a120fe22edbccae708f4f34end can, however, create URLs in the substitution string containing
4e3cdb85620921a8a120fe22edbccae708f4f34end a query string part. Simply use a question mark inside the
4e3cdb85620921a8a120fe22edbccae708f4f34end substitution string to indicate that the following text should
4e3cdb85620921a8a120fe22edbccae708f4f34end be re-injected into the query string. When you want to erase an
4e3cdb85620921a8a120fe22edbccae708f4f34end existing query string, end the substitution string with just a
4e3cdb85620921a8a120fe22edbccae708f4f34end question mark. To combine new and old query strings, use the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>[QSA]</code> flag.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </note>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <p>Additionally you can set special <a name="rewriteflags"
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive id="rewriteflags">actions</a> to be performed by
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive appending <strong><code>[</code><em>flags</em><code>]</code></strong>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive as the third argument to the <code>RewriteRule</code>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive directive. <em>Flags</em> is a comma-separated list, surround by square
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive brackets, of any of the flags in the following table. More
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive details, and examples, for each flag, are available in the <a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive href="/rewrite/flags.html">Rewrite Flags document</a>.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <table border="1">
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <tr><th>Flag and syntax</th>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <th>Function</th>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>B</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>Escape non-alphanumeric characters <em>before</em> applying
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the transformation. <em><a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive href="/rewrite/flags.html#flag_b">details ...</a></em></td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>chain|C</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>Rule is chained to the following rule. If the rule fails,
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the rule(s) chained to it will be skipped. <em><a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive href="/rewrite/flags.html#flag_c">details ...</a></em></td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </tr>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>cookie|CO=<em>NAME</em>:<em>VAL</em></td>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <td>Sets a cookie in the client browser. Full syntax is:
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj 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>
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj </td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </tr>
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj <tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>discardpath|DPI</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>Causes the PATH_INFO portion of the rewritten URI to be
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive discarded. <em><a href="/rewrite/flags.html#flag_dpi">details
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive ...</a></em></td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>env|E=[!]<em>VAR</em>[:<em>VAL</em>]</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>Causes an environment variable <em>VAR</em> to be set (to the
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive value <em>VAL</em> if provided). The form !<em>VAR</em> causes
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive the environment variable <em>VAR</em> to be unset.<em><a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive href="/rewrite/flags.html#flag_e">details ...</a></em></td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>forbidden|F</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>Returns a 403 FORBIDDEN response to the client browser.
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em><a href="/rewrite/flags.html#flag_f">details ...</a></em></td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>gone|G</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>Returns a 410 GONE response to the client browser. <em><a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive href="/rewrite/flags.html#flag_g">details ...</a></em></td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>Handler|H=<em>Content-handler</em></td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>Causes the resulting URI to be sent to the specified
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em>Content-handler</em> for processing. <em><a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive href="/rewrite/flags.html#flag_h">details ...</a></em></td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>last|L</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>Stop the rewriting process immediately and don't apply any
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive more rules. Especially note caveats for per-directory and
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive .htaccess context (see also the END flag). <em><a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive href="/rewrite/flags.html#flag_end">details ...</a></em></td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>next|N</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>Re-run the rewriting process, starting again with the first
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive rule, using the result of the ruleset so far as a starting
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive point. <em><a href="/rewrite/flags.html#flag_n">details
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive ...</a></em></td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>nocase|NC</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>Makes the pattern comparison case-insensitive.
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em><a href="/rewrite/flags.html#flag_nc">details ...</a></em></td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>noescape|NE</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>Prevent mod_rewrite from applying hexcode escaping of
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive special characters in the result of the rewrite. <em><a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive href="/rewrite/flags.html#flag_ne">details ...</a></em></td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>nosubreq|NS</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>Causes a rule to be skipped if the current request is an
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive internal sub-request. <em><a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive href="/rewrite/flags.html#flag_ns">details ...</a></em></td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>proxy|P</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>Force the substitution URL to be internally sent as a proxy
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive request. <em><a href="/rewrite/flags.html#flag_p">details
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive ...</a></em></td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>passthrough|PT</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>Forces the resulting URI to be passed back to the URL
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive mapping engine for processing of other URI-to-filename
630c456b6461158be6cc5c5483735e27b13b4ad5nd translators, such as <code>Alias</code> or
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <code>Redirect</code>. <em><a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive href="/rewrite/flags.html#flag_pt">details ...</a></em></td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>qsappend|QSA</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>Appends any query string from the original request URL to
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive any query string created in the rewrite target.<em><a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive href="/rewrite/flags.html#flag_qsa">details ...</a></em></td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </tr>
630c456b6461158be6cc5c5483735e27b13b4ad5nd <tr>
630c456b6461158be6cc5c5483735e27b13b4ad5nd <td>qsdiscard|QSD</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>Discard any query string attached to the incoming URI.
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em><a href="/rewrite/flags.html#flag_qsd">details
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive ...</a></em></td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>redirect|R[=<em>code</em>]</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>Forces an external redirect, optionally with the specified
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive HTTP status code. <em><a
97a9a944b5887e91042b019776c41d5dd74557aferikabele href="/rewrite/flags.html#flag_r">details ...</a></em>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>END</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>Stop the rewriting process immediately and don't apply any
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive more rules. Also prevents further execution of rewrite rules
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive in per-directory and .htaccess context. (Available in 2.3.9 and later)
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <em><a href="/rewrite/flags.html#flag_l">details ...</a></em></td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>skip|S=<em>num</em></td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>Tells the rewriting engine to skip the next <em>num</em>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive rules if the current rule matches. <em><a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive href="/rewrite/flags.html#flag_s">details ...</a></em></td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>type|T=<em>MIME-type</em></td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <td>Force the <glossary>MIME-type</glossary> of the target file
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive to be the specified type. <em><a
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive href="/rewrite/flags.html#flag_t">details ...</a></em></td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </table>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<note><title>Home directory expansion</title>
97a9a944b5887e91042b019776c41d5dd74557aferikabele<p> When the substitution string begins with a string
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfsliveresembling "/~user" (via explicit text or backreferences), mod_rewrite performs
630c456b6461158be6cc5c5483735e27b13b4ad5ndhome directory expansion independent of the presence or configuration
630c456b6461158be6cc5c5483735e27b13b4ad5ndof <module>mod_userdir</module>.</p>
630c456b6461158be6cc5c5483735e27b13b4ad5nd
630c456b6461158be6cc5c5483735e27b13b4ad5nd<p> This expansion does not occur when the <em>PT</em>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfsliveflag is used on the <directive module="mod_rewrite">RewriteRule</directive>
630c456b6461158be6cc5c5483735e27b13b4ad5nddirective.</p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</note>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive <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 />
97a9a944b5887e91042b019776c41d5dd74557aferikabele for request ``<code>GET
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive /somepath/pathinfo</code>'':</strong><br />
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<table border="1">
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<th>Given Rule</th>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<th>Resulting Substitution</th>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>^/somepath(.*) otherpath$1</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>invalid, not supported</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>^/somepath(.*) otherpath$1 [R]</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>invalid, not supported</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>^/somepath(.*) otherpath$1 [P]</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>invalid, not supported</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>^/somepath(.*) /otherpath$1</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>/otherpath/pathinfo</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>^/somepath(.*) /otherpath$1 [R]</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>http://thishost/otherpath/pathinfo via external redirection</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>^/somepath(.*) /otherpath$1 [P]</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>doesn't make sense, not supported</td>
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj</tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>^/somepath(.*) http://thishost/otherpath$1</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>/otherpath/pathinfo</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<tr>
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj<td>^/somepath(.*) http://thishost/otherpath$1 [R]</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>http://thishost/otherpath/pathinfo via external redirection</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>^/somepath(.*) http://thishost/otherpath$1 [P]</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>doesn't make sense, not supported</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>^/somepath(.*) http://otherhost/otherpath$1</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>http://otherhost/otherpath/pathinfo via external redirection</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>^/somepath(.*) http://otherhost/otherpath$1 [R]</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>http://otherhost/otherpath/pathinfo via external redirection (the [R] flag is redundant)</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
70373b9ee042e7b3be82eee14b17f510fffdacc9slive<tr>
70373b9ee042e7b3be82eee14b17f510fffdacc9slive<td>^/somepath(.*) http://otherhost/otherpath$1 [P]</td>
70373b9ee042e7b3be82eee14b17f510fffdacc9slive<td>http://otherhost/otherpath/pathinfo via internal proxy</td>
70373b9ee042e7b3be82eee14b17f510fffdacc9slive</tr>
70373b9ee042e7b3be82eee14b17f510fffdacc9slive</table>
70373b9ee042e7b3be82eee14b17f510fffdacc9slive
70373b9ee042e7b3be82eee14b17f510fffdacc9slive <p><strong>Inside per-directory configuration for
70373b9ee042e7b3be82eee14b17f510fffdacc9slive <code>/somepath</code><br />
70373b9ee042e7b3be82eee14b17f510fffdacc9slive (<code>/physical/path/to/somepath/.htaccess</code>, with
70373b9ee042e7b3be82eee14b17f510fffdacc9slive <code>RewriteBase /somepath</code>)<br />
70373b9ee042e7b3be82eee14b17f510fffdacc9slive for request ``<code>GET
70373b9ee042e7b3be82eee14b17f510fffdacc9slive /somepath/localpath/pathinfo</code>'':</strong><br />
70373b9ee042e7b3be82eee14b17f510fffdacc9slive </p>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
70373b9ee042e7b3be82eee14b17f510fffdacc9slive<table border="1">
70373b9ee042e7b3be82eee14b17f510fffdacc9slive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<th>Given Rule</th>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<th>Resulting Substitution</th>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>^localpath(.*) otherpath$1</td>
70373b9ee042e7b3be82eee14b17f510fffdacc9slive<td>/somepath/otherpath/pathinfo</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</tr>
70373b9ee042e7b3be82eee14b17f510fffdacc9slive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>^localpath(.*) otherpath$1 [R]</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>http://thishost/somepath/otherpath/pathinfo via external
70373b9ee042e7b3be82eee14b17f510fffdacc9sliveredirection</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>^localpath(.*) otherpath$1 [P]</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>doesn't make sense, not supported</td>
97a9a944b5887e91042b019776c41d5dd74557aferikabele</tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele<tr>
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj<td>^localpath(.*) /otherpath$1</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>/otherpath/pathinfo</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</tr>
013e1ddd21f2142a369c9a9a0eeb6c6a0bc3fcf3patrikj
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>^localpath(.*) /otherpath$1 [R]</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>http://thishost/otherpath/pathinfo via external redirection</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>^localpath(.*) /otherpath$1 [P]</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>doesn't make sense, not supported</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>^localpath(.*) http://thishost/otherpath$1</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>/otherpath/pathinfo</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>^localpath(.*) http://thishost/otherpath$1 [R]</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>http://thishost/otherpath/pathinfo via external redirection</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>^localpath(.*) http://thishost/otherpath$1 [P]</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>doesn't make sense, not supported</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>^localpath(.*) http://otherhost/otherpath$1</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>http://otherhost/otherpath/pathinfo via external redirection</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>^localpath(.*) http://otherhost/otherpath$1 [R]</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>http://otherhost/otherpath/pathinfo via external redirection (the [R] flag is redundant)</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>^localpath(.*) http://otherhost/otherpath$1 [P]</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive<td>http://otherhost/otherpath/pathinfo via internal proxy</td>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</tr>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</table>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </usage>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive </directivesynopsis>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive</modulesynopsis>
1c47b0c72c991a6f0ad172c74df0936fe13d6fbfslive