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