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