mod_rewrite.html.en revision 5da2e4f5e41a00d71f69d6731cb5071a323c5b0d
97a9a944b5887e91042b019776c41d5dd74557aferikabele<?xml version="1.0" encoding="ISO-8859-1"?>
97a9a944b5887e91042b019776c41d5dd74557aferikabele<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
97a9a944b5887e91042b019776c41d5dd74557aferikabele<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
b1ced323143ade589985456a78f3f64d6a6580c5yoshiki XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
b1ced323143ade589985456a78f3f64d6a6580c5yoshiki This file is generated from xml source: DO NOT EDIT
b1ced323143ade589985456a78f3f64d6a6580c5yoshiki XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd -->
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<title>mod_rewrite - Apache HTTP Server</title>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="/style/css/prettify.css" />
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<script src="/style/scripts/prettify.min.js" type="text/javascript">
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</script>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<link href="/images/favicon.ico" rel="shortcut icon" /></head>
52fff662005b1866a3ff09bb6c902800c5cc6dedjerenkrantz<body>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div id="page-header">
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/quickreference.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<p class="apache">Apache HTTP Server Version 2.5</p>
4b5981e276e93df97c34e4da05ca5cf8bbd937dand<img alt="" src="/images/feather.gif" /></div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="/images/left.gif" /></a></div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div id="path">
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd<a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="../">Version 2.5</a> &gt; <a href="./">Modules</a></div>
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd<div id="page-content">
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd<div id="preamble"><h1>Apache Module mod_rewrite</h1>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="toplang">
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<p><span>Available Languages: </span><a href="/en/mod/mod_rewrite.html" title="English">&nbsp;en&nbsp;</a> |
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<a href="/fr/mod/mod_rewrite.html" hreflang="fr" rel="alternate" title="Fran�ais">&nbsp;fr&nbsp;</a></p>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Provides a rule-based rewriting engine to rewrite requested
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4ndURLs on the fly</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="module-dict.html#Status">Status:</a></th><td>Extension</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="module-dict.html#ModuleIdentifier">Module�Identifier:</a></th><td>rewrite_module</td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="module-dict.html#SourceFile">Source�File:</a></th><td>mod_rewrite.c</td></tr></table>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<h3>Summary</h3>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p>The <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> module uses a rule-based rewriting
06ba4a61654b3763ad65f52283832ebf058fdf1cslive engine, based on a PCRE regular-expression parser, to rewrite requested URLs on
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the fly. By default, <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> maps a URL to a filesystem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem path. However, it can also be used to redirect one URL to another URL, or
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem to invoke an internal proxy fetch.</p>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p><code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> 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
06ba4a61654b3763ad65f52283832ebf058fdf1cslive based on server variables, environment variables, HTTP headers, or time
06ba4a61654b3763ad65f52283832ebf058fdf1cslive stamps.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p><code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> operates on the full URL path, including the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem path-info section. A rewrite rule can be invoked in
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>httpd.conf</code> or in <code>.htaccess</code>. The path generated
06ba4a61654b3763ad65f52283832ebf058fdf1cslive by a rewrite rule can include a query string, or can lead to internal
06ba4a61654b3763ad65f52283832ebf058fdf1cslive sub-processing, external request redirection, or internal proxy
06ba4a61654b3763ad65f52283832ebf058fdf1cslive throughput.</p>
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen <p>Further details, discussion, and examples, are provided in the
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <a href="/rewrite/">detailed mod_rewrite documentation</a>.</p>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div id="quickview"><h3 class="directives">Directives</h3>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<ul id="toc">
117c1f888a14e73cdd821dc6c23eb0411144a41cnd<li><img alt="" src="/images/down.gif" /> <a href="#rewritebase">RewriteBase</a></li>
117c1f888a14e73cdd821dc6c23eb0411144a41cnd<li><img alt="" src="/images/down.gif" /> <a href="#rewritecond">RewriteCond</a></li>
117c1f888a14e73cdd821dc6c23eb0411144a41cnd<li><img alt="" src="/images/down.gif" /> <a href="#rewriteengine">RewriteEngine</a></li>
117c1f888a14e73cdd821dc6c23eb0411144a41cnd<li><img alt="" src="/images/down.gif" /> <a href="#rewritemap">RewriteMap</a></li>
117c1f888a14e73cdd821dc6c23eb0411144a41cnd<li><img alt="" src="/images/down.gif" /> <a href="#rewriteoptions">RewriteOptions</a></li>
117c1f888a14e73cdd821dc6c23eb0411144a41cnd<li><img alt="" src="/images/down.gif" /> <a href="#rewriterule">RewriteRule</a></li>
117c1f888a14e73cdd821dc6c23eb0411144a41cnd</ul>
117c1f888a14e73cdd821dc6c23eb0411144a41cnd<h3>Topics</h3>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<ul id="topics">
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<li><img alt="" src="/images/down.gif" /> <a href="#logging">Logging</a></li>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="section">
4c36c711036219c80d5517d35be68a4769c15291slive<h2><a name="logging" id="logging">Logging</a></h2>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
ff21ab9f1cc3037fe58a2029432834581594b6c4pctony <p><code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> offers detailed logging of its actions
ff21ab9f1cc3037fe58a2029432834581594b6c4pctony at the <code>trace1</code> to <code>trace8</code> log levels. The
ff21ab9f1cc3037fe58a2029432834581594b6c4pctony log level can be set specifically for <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd using the <code class="directive"><a href="/mod/core.html#loglevel">LogLevel</a></code> directive: Up to
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd level <code>debug</code>, no actions are logged, while <code>trace8</code>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd means that practically all actions are logged.</p>
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <div class="note">
06ba4a61654b3763ad65f52283832ebf058fdf1cslive Using a high trace log level for <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive will slow down your Apache HTTP Server dramatically! Use a log
06ba4a61654b3763ad65f52283832ebf058fdf1cslive level higher than <code>trace2</code> only for debugging!
b95ae799514ad86a15610ad75808d7065e9847c9kess </div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <div class="example"><h3>Example</h3><pre class="prettyprint lang-config">LogLevel alert rewrite:trace3</pre>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen <div class="note"><h3>RewriteLog</h3>
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen <p>Those familiar with earlier versions of
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> 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
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>To get just the <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code>-specific log
06ba4a61654b3763ad65f52283832ebf058fdf1cslive messages, pipe the log file through grep:</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <div class="example"><p><code>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive tail -f error_log|fgrep '[rewrite:'
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </code></p></div>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem </div>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<div class="directive-section"><h2><a name="RewriteBase" id="RewriteBase">RewriteBase</a> <a name="rewritebase" id="rewritebase">Directive</a></h2>
97a9a944b5887e91042b019776c41d5dd74557aferikabele<table class="directive">
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets the base URL for per-directory rewrites</td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteBase <em>URL-path</em></code></td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>None</code></td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>directory, .htaccess</td></tr>
97a9a944b5887e91042b019776c41d5dd74557aferikabele<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
4c36c711036219c80d5517d35be68a4769c15291slive<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
4c36c711036219c80d5517d35be68a4769c15291slive</table>
4c36c711036219c80d5517d35be68a4769c15291slive <p>The <code class="directive">RewriteBase</code> directive specifies the
4c36c711036219c80d5517d35be68a4769c15291slive URL prefix to be used for per-directory (htaccess)
4c36c711036219c80d5517d35be68a4769c15291slive <code class="directive">RewriteRule</code> directives that substitute a relative
4c36c711036219c80d5517d35be68a4769c15291slive path.</p>
4c36c711036219c80d5517d35be68a4769c15291slive <p> This directive is <em>required</em> when you use a relative path
4c36c711036219c80d5517d35be68a4769c15291slive in a substitution in per-directory (htaccess) context unless either
4c36c711036219c80d5517d35be68a4769c15291slive of the following conditions are true:</p>
4c36c711036219c80d5517d35be68a4769c15291slive <ul>
4c36c711036219c80d5517d35be68a4769c15291slive <li> The original request, and the substitution, are underneath the
f736cd11585a35572d5f42accf026eb667848434slive <code class="directive"><a href="/mod/core.html#documentroot">DocumentRoot</a></code>
4c36c711036219c80d5517d35be68a4769c15291slive (as opposed to reachable by other means, such as
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <code class="directive"><a href="/mod/mod_alias.html#alias">Alias</a></code>).</li>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <li> The <em>filesystem</em> path to the directory containing the
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <code class="directive">RewriteRule</code>, suffixed by the relative
06ba4a61654b3763ad65f52283832ebf058fdf1cslive substitution is also valid as a URL path on the server
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen (this is rare).</li>
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen </ul>
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen<p> In the example below, <code class="directive">RewriteBase</code> is necessary
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen to avoid rewriting to http://example.com/opt/myapp-1.2.3/welcome.html
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd since the resource was not relative to the document root. This
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd misconfiguration would normally cause the server to look for an "opt"
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd directory under the document root.</p>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<pre class="prettyprint lang-config">DocumentRoot /var/www/example.com
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4ndAlias /myapp /opt/myapp-1.2.3
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd&lt;Directory /opt/myapp-1.2.3&gt;
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd RewriteEngine On
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd RewriteBase /myapp/
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd RewriteRule ^index\.html$ welcome.html
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd&lt;/Directory&gt;</pre>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
97a9a944b5887e91042b019776c41d5dd74557aferikabele<div class="directive-section"><h2><a name="RewriteCond" id="RewriteCond">RewriteCond</a> <a name="rewritecond" id="rewritecond">Directive</a></h2>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<table class="directive">
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Defines a condition under which rewriting will take place
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem</td></tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code> RewriteCond
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <em>TestString</em> <em>CondPattern</em></code></td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</table>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>The <code class="directive">RewriteCond</code> directive defines a
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem rule condition. One or more <code class="directive">RewriteCond</code>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive can precede a <code class="directive"><a href="#rewriterule">RewriteRule</a></code>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem directive. The following rule is then only used if both
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the current state of the URI matches its pattern, <strong>and</strong> if these conditions are met.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p><em>TestString</em> is a string which can contain the
97a9a944b5887e91042b019776c41d5dd74557aferikabele following expanded constructs in addition to plain text:</p>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <ul>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <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
97a9a944b5887e91042b019776c41d5dd74557aferikabele <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
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>RewriteCond</code> in the current set
06ba4a61654b3763ad65f52283832ebf058fdf1cslive of conditions. %0 provides access to the whole string matched by
06ba4a61654b3763ad65f52283832ebf058fdf1cslive that pattern.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong>RewriteMap expansions</strong>: These are
97a9a944b5887e91042b019776c41d5dd74557aferikabele expansions of the form <strong><code>${mapname:key|default}</code></strong>.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive 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
97a9a944b5887e91042b019776c41d5dd74557aferikabele 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
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <th>HTTP headers:</th> <th>connection &amp; request:</th> <th />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive HTTP_USER_AGENT<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive HTTP_REFERER<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem HTTP_COOKIE<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem HTTP_FORWARDED<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem HTTP_HOST<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem HTTP_PROXY_CONNECTION<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem HTTP_ACCEPT<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem </td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem REMOTE_ADDR<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele CONN_REMOTE_ADDR<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele REMOTE_HOST<br />
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd REMOTE_PORT<br />
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd REMOTE_USER<br />
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd REMOTE_IDENT<br />
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd REQUEST_METHOD<br />
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd SCRIPT_FILENAME<br />
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd PATH_INFO<br />
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd QUERY_STRING<br />
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd AUTH_TYPE<br />
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd </td>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <td />
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd </tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <th>server internals:</th> <th>date and time:</th> <th>specials:</th>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem </tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive DOCUMENT_ROOT<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem SERVER_ADMIN<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive SERVER_NAME<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive SERVER_ADDR<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive SERVER_PORT<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive SERVER_PROTOCOL<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive SERVER_SOFTWARE<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem </td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem TIME_YEAR<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem TIME_MON<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive TIME_DAY<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive TIME_HOUR<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive TIME_MIN<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem TIME_SEC<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem TIME_WDAY<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem TIME<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem </td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive API_VERSION<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive THE_REQUEST<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem REQUEST_URI<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive REQUEST_FILENAME<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive IS_SUBREQ<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive HTTPS<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive REQUEST_SCHEME<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </table>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>These variables all
06ba4a61654b3763ad65f52283832ebf058fdf1cslive correspond to the similarly named HTTP
06ba4a61654b3763ad65f52283832ebf058fdf1cslive MIME-headers, C variables of the Apache HTTP Server or
97a9a944b5887e91042b019776c41d5dd74557aferikabele <code>struct tm</code> fields of the Unix system.
c6a2d6fa44f8698851dec5051ee3782c2913605fnd Most are documented elsewhere in the Manual or in
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the CGI specification.</p>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
97a9a944b5887e91042b019776c41d5dd74557aferikabele <p>SERVER_NAME and SERVER_PORT depend on the values of
97a9a944b5887e91042b019776c41d5dd74557aferikabele <code class="directive"><a href="/mod/core.html#usecanonicalname">UseCanonicalName</a></code> and
97a9a944b5887e91042b019776c41d5dd74557aferikabele <code class="directive"><a href="/mod/core.html#usecanonicalphysicalport">UseCanonicalPhysicalPort</a></code>
97a9a944b5887e91042b019776c41d5dd74557aferikabele respectively.</p>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
97a9a944b5887e91042b019776c41d5dd74557aferikabele <p>Those that are special to mod_rewrite include those below.</p>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <div class="note">
97a9a944b5887e91042b019776c41d5dd74557aferikabele <dl>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <dt><code>IS_SUBREQ</code></dt>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
97a9a944b5887e91042b019776c41d5dd74557aferikabele <dd>Will contain the text "true" if the request
06ba4a61654b3763ad65f52283832ebf058fdf1cslive currently being processed is a sub-request,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive "false" otherwise. Sub-requests may be generated
06ba4a61654b3763ad65f52283832ebf058fdf1cslive by modules that need to resolve additional files
97a9a944b5887e91042b019776c41d5dd74557aferikabele or URIs in order to complete their tasks.</dd>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
74a6de79356cd15d2e47065087785e36dd65aa41nd <dt><code>API_VERSION</code></dt>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
97a9a944b5887e91042b019776c41d5dd74557aferikabele <dd>This is the version of the Apache httpd module API
97a9a944b5887e91042b019776c41d5dd74557aferikabele (the internal interface between server and
97a9a944b5887e91042b019776c41d5dd74557aferikabele module) in the current httpd build, as defined in
97a9a944b5887e91042b019776c41d5dd74557aferikabele include/ap_mmn.h. The module API version
97a9a944b5887e91042b019776c41d5dd74557aferikabele corresponds to the version of Apache httpd in use (in
97a9a944b5887e91042b019776c41d5dd74557aferikabele the release version of Apache httpd 1.3.14, for
06ba4a61654b3763ad65f52283832ebf058fdf1cslive instance, it is 19990320:10), but is mainly of
97a9a944b5887e91042b019776c41d5dd74557aferikabele interest to module authors.</dd>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dt><code>THE_REQUEST</code></dt>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dd>The full HTTP request line sent by the
53d2fd50ff45e7c568f0588c742a5ef9edf8e275rbowen browser to the server (e.g., "<code>GET
97a9a944b5887e91042b019776c41d5dd74557aferikabele /index.html HTTP/1.1</code>"). This does not
97a9a944b5887e91042b019776c41d5dd74557aferikabele include any additional headers sent by the
97a9a944b5887e91042b019776c41d5dd74557aferikabele browser. This value has not been unescaped
97a9a944b5887e91042b019776c41d5dd74557aferikabele (decoded), unlike most other variables below.</dd>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
97a9a944b5887e91042b019776c41d5dd74557aferikabele <dt><code>REQUEST_URI</code></dt>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
97a9a944b5887e91042b019776c41d5dd74557aferikabele <dd>The path component of the requested URI,
97a9a944b5887e91042b019776c41d5dd74557aferikabele such as "/index.html". This notably excludes the
97a9a944b5887e91042b019776c41d5dd74557aferikabele query string which is available as as its own variable
97a9a944b5887e91042b019776c41d5dd74557aferikabele named <code>QUERY_STRING</code>.</dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dt><code>REQUEST_FILENAME</code></dt>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele <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>. Depending on the value of
97a9a944b5887e91042b019776c41d5dd74557aferikabele <code class="directive"><a href="/mod/core.html#acceptpathinfo">AcceptPathInfo</a></code>, the
97a9a944b5887e91042b019776c41d5dd74557aferikabele server may have only used some leading components of the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>REQUEST_URI</code> to map the request to a file.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
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
fb82af0f0cd7b58eef19c54b086131b7e1e1e749madhum <code class="module"><a href="/mod/mod_ssl.html">mod_ssl</a></code> is loaded).</dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dt><code>REQUEST_SCHEME</code></dt>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dd>Will contain the scheme of the request (usually
06ba4a61654b3763ad65f52283832ebf058fdf1cslive "http" or "https"). This value can be influenced with
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code class="directive"><a href="/mod/core.html#servername">ServerName</a></code>.</dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dt><code>REMOTE_ADDR</code></dt>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dd>The IP address of the remote host (see the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code class="module"><a href="/mod/mod_remoteip.html">mod_remoteip</a></code> module).</dd>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <dt><code>CONN_REMOTE_ADDR</code></dt>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dd>Since 2.4.8: The peer IP address of the connection (see the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code class="module"><a href="/mod/mod_remoteip.html">mod_remoteip</a></code> module).</dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </dl>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </ul>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>If the <em>TestString</em> has the special value <code>expr</code>,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the <em>CondPattern</em> will be treated as an
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <a href="/expr.html">ap_expr</a>. HTTP headers referenced in the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive expression will be added to the Vary header if the <code>novary</code>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive flag is not given.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>Other things you should be aware of:</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <ol>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>The variables SCRIPT_FILENAME and REQUEST_FILENAME
06ba4a61654b3763ad65f52283832ebf058fdf1cslive contain the same value - the value of the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>filename</code> field of the internal
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>request_rec</code> structure of the Apache HTTP Server.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive 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>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>If a substitution occurred and the rewriting continues,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the value of both variables will be updated accordingly.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>If used in per-server context (<em>i.e.</em>, before the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive request is mapped to the filesystem) SCRIPT_FILENAME and
06ba4a61654b3763ad65f52283832ebf058fdf1cslive REQUEST_FILENAME cannot contain the full local filesystem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive path since the path is unknown at this stage of processing.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive Both variables will initially contain the value of REQUEST_URI
06ba4a61654b3763ad65f52283832ebf058fdf1cslive in that case. In order to obtain the full local filesystem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive path of the request in per-server context, use an URL-based
06ba4a61654b3763ad65f52283832ebf058fdf1cslive look-ahead <code>%{LA-U:REQUEST_FILENAME}</code> to determine
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the final value of REQUEST_FILENAME.</p></li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd <li>
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd <code>%{ENV:variable}</code>, where <em>variable</em> can be
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd any environment variable, is also available.
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd This is looked-up via internal
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd Apache httpd structures and (if not found there) via
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>getenv()</code> from the Apache httpd server process.</li>
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd <li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>%{SSL:variable}</code>, where <em>variable</em> is the
97a9a944b5887e91042b019776c41d5dd74557aferikabele name of an <a href="mod_ssl.html#envvars">SSL environment
06ba4a61654b3763ad65f52283832ebf058fdf1cslive variable</a>, can be used whether or not
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code class="module"><a href="/mod/mod_ssl.html">mod_ssl</a></code> is loaded, but will always expand to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the empty string if it is not. Example:
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>%{SSL:SSL_CIPHER_USEKEYSIZE}</code> may expand to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>128</code>.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>%{HTTP:header}</code>, where <em>header</em> can be
06ba4a61654b3763ad65f52283832ebf058fdf1cslive any HTTP MIME-header name, can always be used to obtain the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive value of a header sent in the HTTP request.
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Example: <code>%{HTTP:Proxy-Connection}</code> is
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem the value of the HTTP header
06ba4a61654b3763ad65f52283832ebf058fdf1cslive ``<code>Proxy-Connection:</code>''.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <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
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem to true for the request. It is <strong>not</strong> added if the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem condition evaluates to false for the request. Adding the HTTP header
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem to the Vary header of the response is needed for proper caching.</p>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <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
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <a id="LA-U" name="LA-U"><code>%{LA-U:variable}</code></a>
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd can be used for look-aheads which perform
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem an internal (URL-based) sub-request to determine the final
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd value of <em>variable</em>. This can be used to access
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd variable for rewriting which is not available at the current
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd stage, but will be set in a later phase.
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd <p>For instance, to rewrite according to the
fb82af0f0cd7b58eef19c54b086131b7e1e1e749madhum <code>REMOTE_USER</code> variable from within the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem per-server context (<code>httpd.conf</code> file) you must
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem use <code>%{LA-U:REMOTE_USER}</code> - this
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem variable is set by the authorization phases, which come
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <em>after</em> the URL translation phase (during which mod_rewrite
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem operates).</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>On the other hand, because mod_rewrite implements
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl its per-directory context (<code>.htaccess</code> file) via
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl the Fixup phase of the API and because the authorization
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl phases come <em>before</em> this phase, you just can use
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl <code>%{REMOTE_USER}</code> in that context.</p></li>
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl <li>
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl <code>%{LA-F:variable}</code> can be used to perform an internal
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl (filename-based) sub-request, to determine the final value
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl of <em>variable</em>. Most of the time, this is the same as
06ba4a61654b3763ad65f52283832ebf058fdf1cslive LA-U above.</li>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem </ol>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p><em>CondPattern</em> is the condition pattern,
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem a regular expression which is applied to the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem current instance of the <em>TestString</em>.
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <em>TestString</em> is first evaluated, before being matched against
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <em>CondPattern</em>.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p><em>CondPattern</em> is usually a
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <em>perl compatible regular expression</em>, but there is
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem additional syntax available to perform other useful tests against
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem the <em>Teststring</em>:</p>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <ol>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>You can prefix the pattern string with a
06ba4a61654b3763ad65f52283832ebf058fdf1cslive '<code>!</code>' character (exclamation mark) to specify a
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong>non</strong>-matching pattern.</li>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem You can perform lexicographical string comparisons:
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <ul>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <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
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <em>CondPattern</em>.</li>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <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
630c456b6461158be6cc5c5483735e27b13b4ad5nd <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
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem less than or equal to)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Treats the <em>CondPattern</em> as a plain string and
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem compares it lexicographically to <em>TestString</em>. True
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem if <em>TestString</em> lexicographically precedes
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <em>CondPattern</em>, or is equal to <em>CondPattern</em>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive (the two strings are equal, character for character).</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>'<strong>&gt;=CondPattern</strong>' (lexicographically
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem greater than or equal to)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Treats the <em>CondPattern</em> as a plain string and
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem compares it lexicographically to <em>TestString</em>. True
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem 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>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem </ul></li>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem You can perform integer comparisons:
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <ul>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>'<strong>-eq</strong>' (is numerically
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <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>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>'<strong>-ge</strong>' (is numerically
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <strong>g</strong>reater 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 greater than or equal
06ba4a61654b3763ad65f52283832ebf058fdf1cslive to the <em>CondPattern</em>.</li>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>'<strong>-gt</strong>' (is numerically
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <strong>g</strong>reater <strong>t</strong>han)<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele The <em>TestString</em> is treated as an integer, and is
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem numerically compared to the <em>CondPattern</em>. True if
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem the <em>TestString</em> is numerically greater than
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the <em>CondPattern</em>.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>'<strong>-le</strong>' (is numerically
97a9a944b5887e91042b019776c41d5dd74557aferikabele <strong>l</strong>ess than or <strong>e</strong>qual to)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem The <em>TestString</em> is treated as an integer, and is
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem numerically compared to the <em>CondPattern</em>. True if
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the <em>TestString</em> is numerically less than or equal
4e3cdb85620921a8a120fe22edbccae708f4f34end to the <em>CondPattern</em>. Avoid confusion with the
4e3cdb85620921a8a120fe22edbccae708f4f34end <strong>-l</strong> by using the <strong>-L</strong> or
4e3cdb85620921a8a120fe22edbccae708f4f34end <strong>-h</strong> variant.</li>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>'<strong>-lt</strong>' (is numerically
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <strong>l</strong>ess <strong>t</strong>han)<br />
4e3cdb85620921a8a120fe22edbccae708f4f34end The <em>TestString</em> is treated as an integer, and is
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem numerically compared to the <em>CondPattern</em>. True if
97a9a944b5887e91042b019776c41d5dd74557aferikabele the <em>TestString</em> is numerically less than
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem 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>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem </ul>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </li>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
97a9a944b5887e91042b019776c41d5dd74557aferikabele <li>You can perform various file attribute tests:
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <ul>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>'<strong>-d</strong>' (is
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong>d</strong>irectory)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Treats the <em>TestString</em> as a pathname and tests
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem whether or not it exists, and is a directory.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>'<strong>-f</strong>' (is regular
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <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,
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem accessible via all the server's currently-configured
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem access controls for that path. This uses an internal
06ba4a61654b3763ad65f52283832ebf058fdf1cslive subrequest to do the check, so use it with care -
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem it can impact your server's performance!</li>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
22d5d84393d960a2027f472036f3fee15d7dbce9nd <li>'<strong>-H</strong>' (is symbolic link, bash convention)<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive See <strong>-l</strong>.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>'<strong>-l</strong>' (is symbolic
97a9a944b5887e91042b019776c41d5dd74557aferikabele <strong>l</strong>ink)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Treats the <em>TestString</em> as a pathname and tests
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem whether or not it exists, and is a symbolic link. May also
06ba4a61654b3763ad65f52283832ebf058fdf1cslive use the bash convention of <strong>-L</strong> or
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <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>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>'<strong>-s</strong>' (is regular file, with
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong>s</strong>ize)<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive Treats the <em>TestString</em> as a pathname and tests
97a9a944b5887e91042b019776c41d5dd74557aferikabele whether or not it exists, and is a regular file with size greater
06ba4a61654b3763ad65f52283832ebf058fdf1cslive than zero.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li><p>'<strong>-U</strong>' (is existing URL, via
06ba4a61654b3763ad65f52283832ebf058fdf1cslive subrequest)<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele Checks whether or not <em>TestString</em> is a valid URL,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive accessible via all the server's currently-configured
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem access controls for that path. This uses an internal
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem subrequest to do the check, so use it with care -
06ba4a61654b3763ad65f52283832ebf058fdf1cslive it can impact your server's performance!</p>
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl <p> This flag <em>only</em> returns information about things
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl like access control, authentication, and authorization. This flag
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl <em>does not</em> return information about the status code the
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl configured handler (static file, CGI, proxy, etc.) would have
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl returned.</p> </li>
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl <li>'<strong>-x</strong>' (has e<strong>x</strong>ecutable
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl permissions)<br />
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl Treats the <em>TestString</em> as a pathname and tests
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl whether or not it exists, and has executable permissions.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive These permissions are determined according to
22d5d84393d960a2027f472036f3fee15d7dbce9nd the underlying OS.</li>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </ul>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<div class="note"><h3>Note:</h3>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive All of these tests can
06ba4a61654b3763ad65f52283832ebf058fdf1cslive also be prefixed by an exclamation mark ('!') to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive negate their meaning.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</div>
97a9a944b5887e91042b019776c41d5dd74557aferikabele </li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>If the <em>TestString</em> has the special value <code>expr</code>, the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>CondPattern</em> will be treated as an
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <a href="/expr.html">ap_expr</a>.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>
97a9a944b5887e91042b019776c41d5dd74557aferikabele In the below example, <code>-strmatch</code> is used to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive compare the <code>REFERER</code> against the site hostname,
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem to block unwanted hotlinking.
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem </p>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <pre class="prettyprint lang-config"> RewriteCond expr "! %{HTTP_REFERER} -strmatch '*://%{HTTP_HOST}/*'"<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem RewriteRule ^/images - [F]</pre>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem </li>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>You can also set special flags for
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <em>CondPattern</em> by appending
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong><code>[</code><em>flags</em><code>]</code></strong>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd as the third argument to the <code>RewriteCond</code>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd directive, where <em>flags</em> is a comma-separated list of any of the
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd following flags:
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <ul>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <li>'<strong><code>nocase|NC</code></strong>'
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd (<strong>n</strong>o <strong>c</strong>ase)<br />
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd This makes the test case-insensitive - differences
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd between 'A-Z' and 'a-z' are ignored, both in the
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd expanded <em>TestString</em> and the <em>CondPattern</em>.
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd This flag is effective only for comparisons between
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <em>TestString</em> and <em>CondPattern</em>. It has no
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd effect on filesystem and subrequest checks.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive '<strong><code>ornext|OR</code></strong>'
06ba4a61654b3763ad65f52283832ebf058fdf1cslive (<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<pre class="prettyprint lang-config">RewriteCond %{REMOTE_HOST} ^host1 [OR]
97a9a944b5887e91042b019776c41d5dd74557aferikabeleRewriteCond %{REMOTE_HOST} ^host2 [OR]
06ba4a61654b3763ad65f52283832ebf058fdf1csliveRewriteCond %{REMOTE_HOST} ^host3
4c36c711036219c80d5517d35be68a4769c15291sliveRewriteRule ...some special stuff for any of these hosts...</pre>
4c36c711036219c80d5517d35be68a4769c15291slive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
4c36c711036219c80d5517d35be68a4769c15291slive Without this flag you would have to write the condition/rule
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd pair three times.
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd </li>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <li>'<strong><code>novary|NV</code></strong>'
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd (<strong>n</strong>o <strong>v</strong>ary)<br />
627c978514c54179736d152923478be7c8707f9bnd If a HTTP header is used in the condition, this flag prevents
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd this header from being added to the Vary header of the response. <br />
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd Using this flag might break proper caching of the response if
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd the representation of this response varies on the value of this header.
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd So this flag should be only used if the meaning of the Vary header
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd is well understood.
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd </li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </ul>
97a9a944b5887e91042b019776c41d5dd74557aferikabele </li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </ol>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p><strong>Example:</strong></p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
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<pre class="prettyprint lang-config">RewriteCond %{HTTP_USER_AGENT} (iPhone|Blackberry|Android)
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4ndRewriteRule ^/$ /homepage.mobile.html [L]
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4ndRewriteRule ^/$ /homepage.std.html [L]</pre>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <p>Explanation: If you use a browser which identifies itself
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd as a mobile browser (note that the example is incomplete, as
06ba4a61654b3763ad65f52283832ebf058fdf1cslive there are many other mobile platforms), the mobile version of
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the homepage is served. Otherwise, the standard page is served.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
97a9a944b5887e91042b019776c41d5dd74557aferikabele<div class="directive-section"><h2><a name="RewriteEngine" id="RewriteEngine">RewriteEngine</a> <a name="rewriteengine" id="rewriteengine">Directive</a></h2>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<table class="directive">
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Enables or disables runtime rewriting engine</td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteEngine on|off</code></td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>RewriteEngine off</code></td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
97a9a944b5887e91042b019776c41d5dd74557aferikabele</table>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele <p>The <code class="directive">RewriteEngine</code> directive enables or
06ba4a61654b3763ad65f52283832ebf058fdf1cslive disables the runtime rewriting engine. If it is set to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>off</code> this module does no runtime processing at
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem all. It does not even update the <code>SCRIPT_URx</code>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive environment variables.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele <p>Use this directive to disable rules in a particular contact,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive rather than commenting out all the <code class="directive"><a href="#rewriterule">RewriteRule</a></code> directives.</p>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>Note that rewrite configurations are not
97a9a944b5887e91042b019776c41d5dd74557aferikabele inherited by virtual hosts. This means that you need to have a
97a9a944b5887e91042b019776c41d5dd74557aferikabele <code>RewriteEngine on</code> directive for each virtual host
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd in which you wish to use rewrite rules.</p>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <p><code class="directive">RewriteMap</code> directives of the type <code>prg</code>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd are not started during server initialization if they're defined in a
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd context that does not have <code class="directive">RewriteEngine</code> set to
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <code>on</code></p>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="directive-section"><h2><a name="RewriteMap" id="RewriteMap">RewriteMap</a> <a name="rewritemap" id="rewritemap">Directive</a></h2>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<table class="directive">
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Defines a mapping function for key-lookup</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteMap <em>MapName</em> <em>MapType</em>:<em>MapSource</em>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</code></td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</table>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>The <code class="directive">RewriteMap</code> 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
97a9a944b5887e91042b019776c41d5dd74557aferikabele 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
97a9a944b5887e91042b019776c41d5dd74557aferikabele mapping-function for the substitution strings of a rewriting
06ba4a61654b3763ad65f52283832ebf058fdf1cslive rule via one of the following constructs:</p>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p class="indent">
97a9a944b5887e91042b019776c41d5dd74557aferikabele <strong><code>${</code> <em>MapName</em> <code>:</code>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <em>LookupKey</em> <code>}</code><br />
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <code>${</code> <em>MapName</em> <code>:</code>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <em>LookupKey</em> <code>|</code> <em>DefaultValue</em>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <code>}</code></strong>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd </p>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <p>When such a construct occurs, the map <em>MapName</em> is
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd consulted and the key <em>LookupKey</em> is looked-up. If the
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd key is found, the map-function construct is substituted by
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <em>SubstValue</em>. If the key is not found then it is
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd substituted by <em>DefaultValue</em> or by the empty string
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd if no <em>DefaultValue</em> was specified. Empty values
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd behave as if the key was absent, therefore it is not possible
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd to distinguish between empty-valued keys and absent keys.</p>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>For example, you might define a
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code class="directive">RewriteMap</code> as:</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <pre class="prettyprint lang-config">RewriteMap examplemap txt:/path/to/file/map.txt</pre>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>You would then be able to use this map in a
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code class="directive">RewriteRule</code> as follows:</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <pre class="prettyprint lang-config">RewriteRule ^/ex/(.*) ${examplemap:$1}</pre>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>The following combinations for <em>MapType</em> and
97a9a944b5887e91042b019776c41d5dd74557aferikabele <em>MapSource</em> can be used:</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dl>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele <dt>txt</dt>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dd>A plain text file containing space-separated key-value
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem 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
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen pairs. Hash is constructed from a plain text file format using
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen the <code><a href="/programs/httxt2dbm.html">httxt2dbm</a></code>
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen utility. (<a href="/rewrite/rewritemap.html#dbm">Details ...</a>)</dd>
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen <dt>int</dt>
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen <dd>One of the four available internal functions provided by
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen <code>RewriteMap</code>: toupper, tolower, escape or
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen unescape. (<a href="/rewrite/rewritemap.html#int">Details ...</a>)</dd>
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen <dt>prg</dt>
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen <dd>Calls an external program or script to process the
8ac3ff7008df949c096f9cd8f769c7893594f61fnd rewriting. (<a href="/rewrite/rewritemap.html#prg">Details ...</a>)</dd>
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen <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 href="/rewrite/rewritemap.html">RewriteMap HowTo</a></p>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<div class="directive-section"><h2><a name="RewriteOptions" id="RewriteOptions">RewriteOptions</a> <a name="rewriteoptions" id="rewriteoptions">Directive</a></h2>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<table class="directive">
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets some special options for the rewrite engine</td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteOptions <var>Options</var></code></td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
97a9a944b5887e91042b019776c41d5dd74557aferikabele<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</table>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>The <code class="directive">RewriteOptions</code> directive sets some
97a9a944b5887e91042b019776c41d5dd74557aferikabele 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>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>This forces the current configuration to inherit the
97a9a944b5887e91042b019776c41d5dd74557aferikabele configuration of the parent. In per-virtual-server context,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive this means that the maps, conditions and rules of the main
97a9a944b5887e91042b019776c41d5dd74557aferikabele 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 <code class="directive"><a href="/mod/core.html#directory">&lt;Directory&gt;</a></code>
97a9a944b5887e91042b019776c41d5dd74557aferikabele 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.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <div class="warning">
06ba4a61654b3763ad65f52283832ebf058fdf1cslive Rules inherited from the parent scope are applied
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen <strong>after</strong> rules specified in the child scope.
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen </div>
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen </dd>
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen <dt><code>InheritBefore</code></dt>
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen <dd>
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen <p> Like <code>Inherit</code> above, but the rules from the parent scope
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen are applied <strong>before</strong> rules specified in the child scope.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive Available in Apache HTTP Server 2.3.10 and later.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dt><code>InheritDown</code></dt>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele <p>If this option is enabled, all child configurations will inherit
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the configuration of the current configuration. It is equivalent to
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen specifying <code>RewriteOptions Inherit</code> in all child
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen configurations. See the <code>Inherit</code> option for more details
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen on how the parent-child relationships are handled. Available in Apache
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen HTTP Server 2.4.8 and later.</p>
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen </dd>
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen
97a9a944b5887e91042b019776c41d5dd74557aferikabele <dt><code>InheritDownBefore</code></dt>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>Like <code>InheritDown</code> above, but the rules from the current
97a9a944b5887e91042b019776c41d5dd74557aferikabele scope are applied <strong>before</strong> rules specified in any child's
1578daeec017d3bb20cecdcdc3b0261c999730d5slive scope. Available in Apache HTTP Server 2.4.8 and later.</p>
1578daeec017d3bb20cecdcdc3b0261c999730d5slive </dd>
1578daeec017d3bb20cecdcdc3b0261c999730d5slive
1578daeec017d3bb20cecdcdc3b0261c999730d5slive <dt><code>IgnoreInherit</code></dt>
1578daeec017d3bb20cecdcdc3b0261c999730d5slive <dd>
1578daeec017d3bb20cecdcdc3b0261c999730d5slive
1578daeec017d3bb20cecdcdc3b0261c999730d5slive <p>This option forces the current and child configurations to ignore
1578daeec017d3bb20cecdcdc3b0261c999730d5slive all rules that would be inherited from a parent specifying
ab6f5669a4cb16dbff7d791d434ba1b9c9b50928nd <code>InheritDown</code> or <code>InheritDownBefore</code>. Available
9f7f8f89dfb9115b0b9493049a6ca1ecd8508242rbowen in Apache HTTP Server 2.4.8 and later.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </dd>
9f7f8f89dfb9115b0b9493049a6ca1ecd8508242rbowen
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dt><code>AllowNoSlash</code></dt>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <dd>
9f7f8f89dfb9115b0b9493049a6ca1ecd8508242rbowen <p>By default, <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> will ignore URLs that map to a
97a9a944b5887e91042b019776c41d5dd74557aferikabele directory on disk but lack a trailing slash, in the expectation that
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the <code class="module"><a href="/mod/mod_dir.html">mod_dir</a></code> module will issue the client with a redirect to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the canonical URL with a trailing slash.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele <p>When the <code class="directive"><a href="/mod/mod_dir.html#directoryslash">DirectorySlash</a></code> directive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive is set to off, the <code>AllowNoSlash</code> option can be enabled to ensure
06ba4a61654b3763ad65f52283832ebf058fdf1cslive that rewrite rules are no longer ignored. This option makes it possible to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive apply rewrite rules within .htaccess files that match the directory without
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem a trailing slash, if so desired. Available in Apache HTTP Server 2.4.0 and
06ba4a61654b3763ad65f52283832ebf058fdf1cslive later.</p>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem </dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dt><code>AllowAnyURI</code></dt>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <dd>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>When <code class="directive"><a href="#rewriterule">RewriteRule</a></code>
97a9a944b5887e91042b019776c41d5dd74557aferikabele is used in <code>VirtualHost</code> or server context with
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem version 2.2.22 or later of httpd, <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive will only process the rewrite rules if the request URI is a <a href="directive-dict.html#Syntax">URL-path</a>. This avoids
97a9a944b5887e91042b019776c41d5dd74557aferikabele some security issues where particular rules could allow
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem "surprising" pattern expansions (see <a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-3368">CVE-2011-3368</a>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive and <a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-4317">CVE-2011-4317</a>).
06ba4a61654b3763ad65f52283832ebf058fdf1cslive To lift the restriction on matching a URL-path, the
97a9a944b5887e91042b019776c41d5dd74557aferikabele <code>AllowAnyURI</code> option can be enabled, and
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> will apply the rule set to any
06ba4a61654b3763ad65f52283832ebf058fdf1cslive request URI string, regardless of whether that string matches
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the URL-path grammar required by the HTTP specification.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <div class="warning">
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <h3>Security Warning</h3>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>Enabling this option will make the server vulnerable to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive security issues if used with rewrite rules which are not
06ba4a61654b3763ad65f52283832ebf058fdf1cslive carefully authored. It is <strong>strongly recommended</strong>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive that this option is not used. In particular, beware of input
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem strings containing the '<code>@</code>' character which could
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem change the interpretation of the transformed URI, as per the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive above CVE names.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <dt><code>MergeBase</code></dt>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <dd>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>With this option, the value of <code class="directive"><a href="#rewritebase">RewriteBase</a></code> is copied from where it's explicitly defined
06ba4a61654b3763ad65f52283832ebf058fdf1cslive into any sub-directory or sub-location that doesn't define its own
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code class="directive"><a href="#rewritebase">RewriteBase</a></code>. Available in
06ba4a61654b3763ad65f52283832ebf058fdf1cslive Apache HTTP Server 2.5 and later only.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </dl>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
97a9a944b5887e91042b019776c41d5dd74557aferikabele<div class="directive-section"><h2><a name="RewriteRule" id="RewriteRule">RewriteRule</a> <a name="rewriterule" id="rewriterule">Directive</a></h2>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<table class="directive">
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Defines rules for the rewriting engine</td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteRule
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>Pattern</em> <em>Substitution</em> [<em>flags</em>]</code></td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
97a9a944b5887e91042b019776c41d5dd74557aferikabele<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</table>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>The <code class="directive">RewriteRule</code> directive is the real
06ba4a61654b3763ad65f52283832ebf058fdf1cslive rewriting workhorse. The directive can occur more than once,
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem with each instance defining a single rewrite rule. The
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem order in which these rules are defined is important - this is the order
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem in which they will be applied at run-time.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p><a id="patterns" name="patterns"><em>Pattern</em></a> is
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem a perl compatible <a id="regexp" name="regexp">regular
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem expression</a>. On the first RewriteRule, it is matched against
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the (%-decoded) <a href="directive-dict.html#Syntax">URL-path</a> (or
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <a href="directive-dict.html#Syntax">file-path</a>, depending
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem on the context) of the request. Subsequent patterns are matched against the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem output of the last matching RewriteRule.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<div class="note"><h3><a id="what_is_matched" name="what_is_matched">What is matched?</a></h3>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>In <code class="directive"><a href="/mod/core.html#virtualhost">VirtualHost</a></code> context,
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd The <em>Pattern</em> will initially be matched against the part of the
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd URL after the hostname and port, and before the query string (e.g. "/app1/index.html").</p>
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd <p>In <code class="directive"><a href="/mod/core.html#directory">Directory</a></code> and htaccess context,
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd the <em>Pattern</em> will initially be matched against the
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd <em>filesystem</em> path, after removing the prefix that led the server
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd to the current <code class="directive">RewriteRule</code> (e.g. "app1/index.html"
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd or "index.html" depending on where the directives are defined).</p>
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd <p>If you wish to match against the hostname, port, or query string, use a
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd <code class="directive"><a href="#rewritecond">RewriteCond</a></code> with the
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd <code>%{HTTP_HOST}</code>, <code>%{SERVER_PORT}</code>, or
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd <code>%{QUERY_STRING}</code> variables respectively.</p>
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd</div>
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd<div class="note"><h3>Per-directory Rewrites</h3>
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd<ul>
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd<li>The rewrite engine may be used in <a href="/howto/htaccess.html">.htaccess</a> files and in <code class="directive"><a href="/mod/core.html#directory">&lt;Directory&gt;</a></code> sections, with some additional
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisdcomplexity.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<li>To enable the rewrite engine in this context, 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.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele<li>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 RewriteRule pattern matching
06ba4a61654b3763ad65f52283832ebf058fdf1csliveand automatically <em>added</em> after any relative (not starting with a
06ba4a61654b3763ad65f52283832ebf058fdf1csliveslash or protocol name) substitution encounters the end of a rule set.
06ba4a61654b3763ad65f52283832ebf058fdf1csliveSee the <code class="directive"><a href="#rewritebase">RewriteBase</a></code>
97a9a944b5887e91042b019776c41d5dd74557aferikabeledirective for more information regarding what prefix will be added back to
06ba4a61654b3763ad65f52283832ebf058fdf1csliverelative substitutions.</li>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<li> If you wish to match against the full URL-path in a per-directory
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd(htaccess) RewriteRule, use the <code>%{REQUEST_URI}</code> variable in
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nda <code class="directive">RewriteCond</code>.</li>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<li>The removed prefix always ends with a slash, meaning the matching occurs against a string which
0203b896e484dfb877111aceffb812401d0f216and<em>never</em> has a leading slash. Therefore, a <em>Pattern</em> with <code>^/</code> never
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4ndmatches in per-directory context.</li>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<li>Although rewrite rules are syntactically permitted in <code class="directive"><a href="/mod/core.html#location">&lt;Location&gt;</a></code> and <code class="directive"><a href="/mod/core.html#files">&lt;Files&gt;</a></code> sections, this
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4ndshould never be necessary and is unsupported.</li>
844def494f17cb1ab0983427d5c3939e1a03ff8cnd</ul>
0203b896e484dfb877111aceffb812401d0f216and</div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>For some hints on <a class="glossarylink" href="/glossary.html#regex" title="see glossary">regular
06ba4a61654b3763ad65f52283832ebf058fdf1cslive expressions</a>, see
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the <a href="/rewrite/intro.html#regex">mod_rewrite
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Introduction</a>.</p>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>In mod_rewrite, the NOT character
0203b896e484dfb877111aceffb812401d0f216and ('<code>!</code>') is also available as a possible pattern
0203b896e484dfb877111aceffb812401d0f216and prefix. This enables you to negate a pattern; to say, for instance:
0203b896e484dfb877111aceffb812401d0f216and ``<em>if the current URL does <strong>NOT</strong> match this
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem pattern</em>''. This can be used for exceptional cases, where
0203b896e484dfb877111aceffb812401d0f216and it is easier to match the negative pattern, or as a last
0203b896e484dfb877111aceffb812401d0f216and default rule.</p>
0203b896e484dfb877111aceffb812401d0f216and
0203b896e484dfb877111aceffb812401d0f216and<div class="note"><h3>Note</h3>
0203b896e484dfb877111aceffb812401d0f216andWhen 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</div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <p>The <a id="rhs" name="rhs"><em>Substitution</em></a> of a
96147932f199be4ad038778e702c13a2f79051c0slive rewrite rule is the string that replaces the original URL-path that
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd was matched by <em>Pattern</em>. The <em>Substitution</em> may
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd be a:</p>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <dl>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dt>file-system path</dt>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <dd>Designates the location on the file-system of the resource
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem to be delivered to the client. Substitutions are only
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem treated as a file-system path when the rule is configured in
06ba4a61654b3763ad65f52283832ebf058fdf1cslive server (virtualhost) context and the first component of the
630c456b6461158be6cc5c5483735e27b13b4ad5nd path in the substitution exists in the file-system</dd>
630c456b6461158be6cc5c5483735e27b13b4ad5nd
8c8c2e71c84babf0e8c4b35819c7c5b3be014cfenoodl <dt>URL-path</dt>
8c8c2e71c84babf0e8c4b35819c7c5b3be014cfenoodl
8c8c2e71c84babf0e8c4b35819c7c5b3be014cfenoodl <dd>A <code class="directive"><a href="/mod/core.html#documentroot">DocumentRoot</a></code>-relative path to the
8c8c2e71c84babf0e8c4b35819c7c5b3be014cfenoodl resource to be served. Note that <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive tries to guess whether you have specified a file-system path
96147932f199be4ad038778e702c13a2f79051c0slive or a URL-path by checking to see if the first segment of the
96147932f199be4ad038778e702c13a2f79051c0slive path exists at the root of the file-system. For example, if
96147932f199be4ad038778e702c13a2f79051c0slive you specify a <em>Substitution</em> string of
96147932f199be4ad038778e702c13a2f79051c0slive <code>/www/file.html</code>, then this will be treated as a
96147932f199be4ad038778e702c13a2f79051c0slive URL-path <em>unless</em> a directory named <code>www</code>
96147932f199be4ad038778e702c13a2f79051c0slive exists at the root or your file-system (or, in the case of
96147932f199be4ad038778e702c13a2f79051c0slive using rewrites in a <code>.htaccess</code> file, relative to
96147932f199be4ad038778e702c13a2f79051c0slive your document root), in which case it will
96147932f199be4ad038778e702c13a2f79051c0slive be treated as a file-system path. If you wish other
96147932f199be4ad038778e702c13a2f79051c0slive URL-mapping directives (such as <code class="directive"><a href="/mod/mod_alias.html#alias">Alias</a></code>) to be applied to the
96147932f199be4ad038778e702c13a2f79051c0slive resulting URL-path, use the <code>[PT]</code> flag as
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem described below.</dd>
d1348237b33bc1755b9f1165eea52317465a7671nd
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dt>Absolute URL</dt>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dd>If an absolute URL is specified,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> checks to see whether the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem hostname matches the current host. If it does, the scheme and
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem hostname are stripped out and the resulting path is treated as
06ba4a61654b3763ad65f52283832ebf058fdf1cslive a URL-path. Otherwise, an external redirect is performed for
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the given URL. To force an external redirect back to the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive current host, see the <code>[R]</code> flag below.</dd>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <dt><code>-</code> (dash)</dt>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
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
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem the path.</dd>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem </dl>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>In addition to plain text, the <em>Substitution</em> string can include</p>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <ol>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>back-references (<code>$N</code>) to the RewriteRule
06ba4a61654b3763ad65f52283832ebf058fdf1cslive pattern</li>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>back-references (<code>%N</code>) to the last matched
97a9a944b5887e91042b019776c41d5dd74557aferikabele RewriteCond pattern</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>server-variables as in rule condition test-strings
8c44fe1bc3c69c843dc48f744e062cc4422e7726nd (<code>%{VARNAME}</code>)</li>
630c456b6461158be6cc5c5483735e27b13b4ad5nd
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li><a href="#mapfunc">mapping-function</a> calls
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem (<code>${mapname:key|default}</code>)</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </ol>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
edc8d9e0cce625a77afd1ff87a8f955694a973e2rbowen <p>Back-references are identifiers of the form
97a9a944b5887e91042b019776c41d5dd74557aferikabele <code>$</code><strong>N</strong>
edc8d9e0cce625a77afd1ff87a8f955694a973e2rbowen (<strong>N</strong>=0..9), which will be replaced
edc8d9e0cce625a77afd1ff87a8f955694a973e2rbowen 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>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem directive. The mapping-functions come from the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>RewriteMap</code> directive and are explained there.
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem These three types of variables are expanded in the order above.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>Rewrite rules are applied to the results of previous rewrite
06ba4a61654b3763ad65f52283832ebf058fdf1cslive rules, in the order in which they are defined
06ba4a61654b3763ad65f52283832ebf058fdf1cslive in the config file. The URL-path or file-system path (see <a href="#what_is_matched">"What is matched?"</a>, above) is <strong>completely
06ba4a61654b3763ad65f52283832ebf058fdf1cslive replaced</strong> by the <em>Substitution</em> and the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem rewriting process continues until all rules have been applied,
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem or it is explicitly terminated by an
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <a href="/rewrite/flags.html#flag_l"><code><strong>L</strong></code> flag</a>,
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem or other flag which implies immediate termination, such as
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code><strong>END</strong></code> or
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code><strong>F</strong></code>.</p>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <div class="note"><h3>Modifying the Query String</h3>
96147932f199be4ad038778e702c13a2f79051c0slive <p>By default, the query string is passed through unchanged. You
96147932f199be4ad038778e702c13a2f79051c0slive can, however, create URLs in the substitution string containing
96147932f199be4ad038778e702c13a2f79051c0slive a query string part. Simply use a question mark inside the
96147932f199be4ad038778e702c13a2f79051c0slive substitution string to indicate that the following text should
96147932f199be4ad038778e702c13a2f79051c0slive be re-injected into the query string. When you want to erase an
96147932f199be4ad038778e702c13a2f79051c0slive existing query string, end the substitution string with just a
96147932f199be4ad038778e702c13a2f79051c0slive question mark. To combine new and old query strings, use the
96147932f199be4ad038778e702c13a2f79051c0slive <code>[QSA]</code> flag.</p>
96147932f199be4ad038778e702c13a2f79051c0slive </div>
96147932f199be4ad038778e702c13a2f79051c0slive
96147932f199be4ad038778e702c13a2f79051c0slive <p>Additionally you can set special <a name="rewriteflags" id="rewriteflags">actions</a> to be performed by
96147932f199be4ad038778e702c13a2f79051c0slive appending <strong><code>[</code><em>flags</em><code>]</code></strong>
96147932f199be4ad038778e702c13a2f79051c0slive as the third argument to the <code>RewriteRule</code>
96147932f199be4ad038778e702c13a2f79051c0slive directive. <em>Flags</em> is a comma-separated list, surround by square
96147932f199be4ad038778e702c13a2f79051c0slive brackets, of any of the flags in the following table. More
96147932f199be4ad038778e702c13a2f79051c0slive details, and examples, for each flag, are available in the <a href="/rewrite/flags.html">Rewrite Flags document</a>.</p>
96147932f199be4ad038778e702c13a2f79051c0slive
e00def5e805da9a73b72ad25dac664f0c8c36c2end <table class="bordered">
96147932f199be4ad038778e702c13a2f79051c0slive <tr><th>Flag and syntax</th>
96147932f199be4ad038778e702c13a2f79051c0slive <th>Function</th>
96147932f199be4ad038778e702c13a2f79051c0slive </tr>
96147932f199be4ad038778e702c13a2f79051c0slive <tr>
96147932f199be4ad038778e702c13a2f79051c0slive <td>B</td>
96147932f199be4ad038778e702c13a2f79051c0slive <td>Escape non-alphanumeric characters in backreferences <em>before</em>
96147932f199be4ad038778e702c13a2f79051c0slive applying the transformation. <em><a href="/rewrite/flags.html#flag_b">details ...</a></em></td>
96147932f199be4ad038778e702c13a2f79051c0slive </tr>
96147932f199be4ad038778e702c13a2f79051c0slive <tr>
96147932f199be4ad038778e702c13a2f79051c0slive <td>chain|C</td>
96147932f199be4ad038778e702c13a2f79051c0slive <td>Rule is chained to the following rule. If the rule fails,
96147932f199be4ad038778e702c13a2f79051c0slive the rule(s) chained to it will be skipped. <em><a href="/rewrite/flags.html#flag_c">details ...</a></em></td>
96147932f199be4ad038778e702c13a2f79051c0slive </tr>
96147932f199be4ad038778e702c13a2f79051c0slive <tr>
96147932f199be4ad038778e702c13a2f79051c0slive <td>cookie|CO=<em>NAME</em>:<em>VAL</em></td>
96147932f199be4ad038778e702c13a2f79051c0slive <td>Sets a cookie in the client browser. Full syntax is:
96147932f199be4ad038778e702c13a2f79051c0slive 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>
96147932f199be4ad038778e702c13a2f79051c0slive </td>
96147932f199be4ad038778e702c13a2f79051c0slive </tr>
96147932f199be4ad038778e702c13a2f79051c0slive <tr>
96147932f199be4ad038778e702c13a2f79051c0slive <td>discardpath|DPI</td>
96147932f199be4ad038778e702c13a2f79051c0slive <td>Causes the PATH_INFO portion of the rewritten URI to be
96147932f199be4ad038778e702c13a2f79051c0slive discarded. <em><a href="/rewrite/flags.html#flag_dpi">details
96147932f199be4ad038778e702c13a2f79051c0slive ...</a></em></td>
96147932f199be4ad038778e702c13a2f79051c0slive </tr>
96147932f199be4ad038778e702c13a2f79051c0slive <tr>
96147932f199be4ad038778e702c13a2f79051c0slive <td>END</td>
96147932f199be4ad038778e702c13a2f79051c0slive <td>Stop the rewriting process immediately and don't apply any
96147932f199be4ad038778e702c13a2f79051c0slive more rules. Also prevents further execution of rewrite rules
96147932f199be4ad038778e702c13a2f79051c0slive in per-directory and .htaccess context. (Available in 2.3.9 and later)
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em><a href="/rewrite/flags.html#flag_end">details ...</a></em></td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <td>env|E=[!]<em>VAR</em>[:<em>VAL</em>]</td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <td>Causes an environment variable <em>VAR</em> to be set (to the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem value <em>VAL</em> if provided). The form !<em>VAR</em> causes
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the environment variable <em>VAR</em> to be unset.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em><a href="/rewrite/flags.html#flag_e">details ...</a></em></td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <td>forbidden|F</td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <td>Returns a 403 FORBIDDEN response to the client browser.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em><a href="/rewrite/flags.html#flag_f">details ...</a></em></td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </tr>
96147932f199be4ad038778e702c13a2f79051c0slive <tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <td>gone|G</td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <td>Returns a 410 GONE response to the client browser. <em><a href="/rewrite/flags.html#flag_g">details ...</a></em></td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem </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 href="/rewrite/flags.html#flag_h">details ...</a></em></td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <td>last|L</td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <td>Stop the rewriting process immediately and don't apply any
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem more rules. Especially note caveats for per-directory and
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem .htaccess context (see also the END flag). <em><a href="/rewrite/flags.html#flag_l">details ...</a></em></td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem </tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <td>next|N</td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <td>Re-run the rewriting process, starting again with the first
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem rule, using the result of the ruleset so far as a starting
06ba4a61654b3763ad65f52283832ebf058fdf1cslive point. <em><a href="/rewrite/flags.html#flag_n">details
96147932f199be4ad038778e702c13a2f79051c0slive ...</a></em></td>
96147932f199be4ad038778e702c13a2f79051c0slive </tr>
96147932f199be4ad038778e702c13a2f79051c0slive <tr>
96147932f199be4ad038778e702c13a2f79051c0slive <td>nocase|NC</td>
96147932f199be4ad038778e702c13a2f79051c0slive <td>Makes the pattern comparison case-insensitive.
96147932f199be4ad038778e702c13a2f79051c0slive <em><a href="/rewrite/flags.html#flag_nc">details ...</a></em></td>
96147932f199be4ad038778e702c13a2f79051c0slive </tr>
96147932f199be4ad038778e702c13a2f79051c0slive <tr>
96147932f199be4ad038778e702c13a2f79051c0slive <td>noescape|NE</td>
96147932f199be4ad038778e702c13a2f79051c0slive <td>Prevent mod_rewrite from applying hexcode escaping of
70373b9ee042e7b3be82eee14b17f510fffdacc9slive special characters in the result of the rewrite. <em><a href="/rewrite/flags.html#flag_ne">details ...</a></em></td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </tr>
ff21ab9f1cc3037fe58a2029432834581594b6c4pctony <tr>
96147932f199be4ad038778e702c13a2f79051c0slive <td>nosubreq|NS</td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <td>Causes a rule to be skipped if the current request is an
06ba4a61654b3763ad65f52283832ebf058fdf1cslive internal sub-request. <em><a href="/rewrite/flags.html#flag_ns">details ...</a></em></td>
96147932f199be4ad038778e702c13a2f79051c0slive </tr>
96147932f199be4ad038778e702c13a2f79051c0slive <tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <td>proxy|P</td>
8a571abb6573d916da05fc8b9f04fd944ad45803slive <td>Force the substitution URL to be internally sent as a proxy
8a7ed8b6e3f5b266680dba1c890d1b9c6c0426efnoodl request. <em><a href="/rewrite/flags.html#flag_p">details
8a7ed8b6e3f5b266680dba1c890d1b9c6c0426efnoodl ...</a></em></td>
8a7ed8b6e3f5b266680dba1c890d1b9c6c0426efnoodl </tr>
8a7ed8b6e3f5b266680dba1c890d1b9c6c0426efnoodl <tr>
8a7ed8b6e3f5b266680dba1c890d1b9c6c0426efnoodl <td>passthrough|PT</td>
68e9d372e2a31a4b2575b2db3ec980dc9a4ea325noodl <td>Forces the resulting URI to be passed back to the URL
1e483b59c4b4124ab0036d26b147ad93629943b7noodl mapping engine for processing of other URI-to-filename
8a7ed8b6e3f5b266680dba1c890d1b9c6c0426efnoodl translators, such as <code>Alias</code> or
1e483b59c4b4124ab0036d26b147ad93629943b7noodl <code>Redirect</code>. <em><a href="/rewrite/flags.html#flag_pt">details ...</a></em></td>
8a7ed8b6e3f5b266680dba1c890d1b9c6c0426efnoodl </tr>
1e483b59c4b4124ab0036d26b147ad93629943b7noodl <tr>
8a7ed8b6e3f5b266680dba1c890d1b9c6c0426efnoodl <td>qsappend|QSA</td>
8a7ed8b6e3f5b266680dba1c890d1b9c6c0426efnoodl <td>Appends any query string from the original request URL to
8a7ed8b6e3f5b266680dba1c890d1b9c6c0426efnoodl any query string created in the rewrite target.<em><a href="/rewrite/flags.html#flag_qsa">details ...</a></em></td>
8a7ed8b6e3f5b266680dba1c890d1b9c6c0426efnoodl </tr>
8a571abb6573d916da05fc8b9f04fd944ad45803slive <tr>
8a571abb6573d916da05fc8b9f04fd944ad45803slive <td>qsdiscard|QSD</td>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen <td>Discard any query string attached to the incoming URI.
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen <em><a href="/rewrite/flags.html#flag_qsd">details
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem ...</a></em></td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem </tr>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen <tr>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen <td>redirect|R[=<em>code</em>]</td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <td>Forces an external redirect, optionally with the specified
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem HTTP status code. <em><a href="/rewrite/flags.html#flag_r">details ...</a></em>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen </td>
8a571abb6573d916da05fc8b9f04fd944ad45803slive </tr>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen <tr>
8a7ed8b6e3f5b266680dba1c890d1b9c6c0426efnoodl <td>skip|S=<em>num</em></td>
8a571abb6573d916da05fc8b9f04fd944ad45803slive <td>Tells the rewriting engine to skip the next <em>num</em>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem rules if the current rule matches. <em><a href="/rewrite/flags.html#flag_s">details ...</a></em></td>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen </tr>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen <tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <td>type|T=<em>MIME-type</em></td>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen <td>Force the <a class="glossarylink" href="/glossary.html#mime-type" title="see glossary">MIME-type</a> of the target file
8a571abb6573d916da05fc8b9f04fd944ad45803slive to be the specified type. <em><a href="/rewrite/flags.html#flag_t">details ...</a></em></td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </tr>
8a571abb6573d916da05fc8b9f04fd944ad45803slive </table>
8a571abb6573d916da05fc8b9f04fd944ad45803slive
8a571abb6573d916da05fc8b9f04fd944ad45803slive<div class="note"><h3>Home directory expansion</h3>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<p> When the substitution string begins with a string
173a6aaf8f8d2c818ab71d3781400e521051a565rbowenresembling "/~user" (via explicit text or backreferences), mod_rewrite performs
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluemhome directory expansion independent of the presence or configuration
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluemof <code class="module"><a href="/mod/mod_userdir.html">mod_userdir</a></code>.</p>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<p> This expansion does not occur when the <em>PT</em>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluemflag is used on the <code class="directive"><a href="#rewriterule">RewriteRule</a></code>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluemdirective.</p>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem</div>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
8a571abb6573d916da05fc8b9f04fd944ad45803slive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>Here are all possible substitution combinations and their
8a571abb6573d916da05fc8b9f04fd944ad45803slive meanings:</p>
8a571abb6573d916da05fc8b9f04fd944ad45803slive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p><strong>Inside per-server configuration
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem (<code>httpd.conf</code>)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem for request ``<code>GET
06ba4a61654b3763ad65f52283832ebf058fdf1cslive /somepath/pathinfo</code>'':</strong><br />
8a571abb6573d916da05fc8b9f04fd944ad45803slive </p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
8a571abb6573d916da05fc8b9f04fd944ad45803slive<table class="bordered">
8a571abb6573d916da05fc8b9f04fd944ad45803slive<tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<th>Given Rule</th>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<th>Resulting Substitution</th>
8a571abb6573d916da05fc8b9f04fd944ad45803slive</tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
8a571abb6573d916da05fc8b9f04fd944ad45803slive<tr>
8a571abb6573d916da05fc8b9f04fd944ad45803slive<td>^/somepath(.*) otherpath$1</td>
8a571abb6573d916da05fc8b9f04fd944ad45803slive<td>invalid, not supported</td>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen</tr>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<td>^/somepath(.*) otherpath$1 [R]</td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<td>invalid, not supported</td>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen</tr>
8a571abb6573d916da05fc8b9f04fd944ad45803slive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr>
8a571abb6573d916da05fc8b9f04fd944ad45803slive<td>^/somepath(.*) otherpath$1 [P]</td>
8a571abb6573d916da05fc8b9f04fd944ad45803slive<td>invalid, not supported</td>
8ed0917f332087770872e032b248b2e1e689df3bslive</tr>
8ed0917f332087770872e032b248b2e1e689df3bslive
8ed0917f332087770872e032b248b2e1e689df3bslive<tr>
8ed0917f332087770872e032b248b2e1e689df3bslive<td>^/somepath(.*) /otherpath$1</td>
8ed0917f332087770872e032b248b2e1e689df3bslive<td>/otherpath/pathinfo</td>
8ed0917f332087770872e032b248b2e1e689df3bslive</tr>
8ed0917f332087770872e032b248b2e1e689df3bslive
8ed0917f332087770872e032b248b2e1e689df3bslive<tr>
8ed0917f332087770872e032b248b2e1e689df3bslive<td>^/somepath(.*) /otherpath$1 [R]</td>
8a571abb6573d916da05fc8b9f04fd944ad45803slive<td>http://thishost/otherpath/pathinfo via external redirection</td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</tr>
8a571abb6573d916da05fc8b9f04fd944ad45803slive
8a571abb6573d916da05fc8b9f04fd944ad45803slive<tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<td>^/somepath(.*) /otherpath$1 [P]</td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<td>doesn't make sense, not supported</td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem</tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<td>^/somepath(.*) http://thishost/otherpath$1</td>
8a571abb6573d916da05fc8b9f04fd944ad45803slive<td>/otherpath/pathinfo</td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem</tr>
8a571abb6573d916da05fc8b9f04fd944ad45803slive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr>
8a571abb6573d916da05fc8b9f04fd944ad45803slive<td>^/somepath(.*) http://thishost/otherpath$1 [R]</td>
8a571abb6573d916da05fc8b9f04fd944ad45803slive<td>http://thishost/otherpath/pathinfo via external redirection</td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem</tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen<tr>
8a571abb6573d916da05fc8b9f04fd944ad45803slive<td>^/somepath(.*) http://thishost/otherpath$1 [P]</td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<td>doesn't make sense, not supported</td>
8a571abb6573d916da05fc8b9f04fd944ad45803slive</tr>
8a571abb6573d916da05fc8b9f04fd944ad45803slive
8a571abb6573d916da05fc8b9f04fd944ad45803slive<tr>
8a571abb6573d916da05fc8b9f04fd944ad45803slive<td>^/somepath(.*) http://otherhost/otherpath$1</td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<td>http://otherhost/otherpath/pathinfo via external redirection</td>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen</tr>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen<tr>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen<td>^/somepath(.*) http://otherhost/otherpath$1 [R]</td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<td>http://otherhost/otherpath/pathinfo via external redirection (the [R] flag is redundant)</td>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen</tr>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen<tr>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen<td>^/somepath(.*) http://otherhost/otherpath$1 [P]</td>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen<td>http://otherhost/otherpath/pathinfo via internal proxy</td>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen</tr>
8a571abb6573d916da05fc8b9f04fd944ad45803slive</table>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
8a571abb6573d916da05fc8b9f04fd944ad45803slive <p><strong>Inside per-directory configuration for
8a571abb6573d916da05fc8b9f04fd944ad45803slive <code>/somepath</code><br />
8a571abb6573d916da05fc8b9f04fd944ad45803slive (<code>/physical/path/to/somepath/.htaccess</code>, with
8a571abb6573d916da05fc8b9f04fd944ad45803slive <code>RewriteBase /somepath</code>)<br />
8a571abb6573d916da05fc8b9f04fd944ad45803slive for request ``<code>GET
06ba4a61654b3763ad65f52283832ebf058fdf1cslive /somepath/localpath/pathinfo</code>'':</strong><br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </p>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<table class="bordered">
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<th>Given Rule</th>
8a571abb6573d916da05fc8b9f04fd944ad45803slive<th>Resulting Substitution</th>
8a571abb6573d916da05fc8b9f04fd944ad45803slive</tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<td>^localpath(.*) otherpath$1</td>
8a571abb6573d916da05fc8b9f04fd944ad45803slive<td>/somepath/otherpath/pathinfo</td>
8a571abb6573d916da05fc8b9f04fd944ad45803slive</tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
8a571abb6573d916da05fc8b9f04fd944ad45803slive<tr>
8a571abb6573d916da05fc8b9f04fd944ad45803slive<td>^localpath(.*) otherpath$1 [R]</td>
8a571abb6573d916da05fc8b9f04fd944ad45803slive<td>http://thishost/somepath/otherpath/pathinfo via external
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluemredirection</td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem</tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen<tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<td>^localpath(.*) otherpath$1 [P]</td>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen<td>doesn't make sense, not supported</td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem</tr>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen<tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<td>^localpath(.*) /otherpath$1</td>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen<td>/otherpath/pathinfo</td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
9b82bd7c7f2083318e7856831dede324534308bcrbowen<tr>
8a571abb6573d916da05fc8b9f04fd944ad45803slive<td>^localpath(.*) /otherpath$1 [R]</td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<td>http://thishost/otherpath/pathinfo via external redirection</td>
8a571abb6573d916da05fc8b9f04fd944ad45803slive</tr>
8a571abb6573d916da05fc8b9f04fd944ad45803slive
8a571abb6573d916da05fc8b9f04fd944ad45803slive<tr>
8a571abb6573d916da05fc8b9f04fd944ad45803slive<td>^localpath(.*) /otherpath$1 [P]</td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<td>doesn't make sense, not supported</td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<td>^localpath(.*) http://thishost/otherpath$1</td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<td>/otherpath/pathinfo</td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<td>^localpath(.*) http://thishost/otherpath$1 [R]</td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<td>http://thishost/otherpath/pathinfo via external redirection</td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem</tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
97a9a944b5887e91042b019776c41d5dd74557aferikabele<tr>
97a9a944b5887e91042b019776c41d5dd74557aferikabele<td>^localpath(.*) http://thishost/otherpath$1 [P]</td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<td>doesn't make sense, not supported</td>
97a9a944b5887e91042b019776c41d5dd74557aferikabele</tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<td>^localpath(.*) http://otherhost/otherpath$1</td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<td>http://otherhost/otherpath/pathinfo via external redirection</td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<td>^localpath(.*) http://otherhost/otherpath$1 [R]</td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<td>http://otherhost/otherpath/pathinfo via external redirection (the [R] flag is redundant)</td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem</tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<td>^localpath(.*) http://otherhost/otherpath$1 [P]</td>
b5407b0669a6a7175c84859e727d133399e4fa51slive<td>http://otherhost/otherpath/pathinfo via internal proxy</td>
b5407b0669a6a7175c84859e727d133399e4fa51slive</tr>
b5407b0669a6a7175c84859e727d133399e4fa51slive
b5407b0669a6a7175c84859e727d133399e4fa51slive</table>
8a571abb6573d916da05fc8b9f04fd944ad45803slive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
8a571abb6573d916da05fc8b9f04fd944ad45803slive</div>
8a571abb6573d916da05fc8b9f04fd944ad45803slive</div>
8a571abb6573d916da05fc8b9f04fd944ad45803slive<div class="bottomlang">
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<p><span>Available Languages: </span><a href="/en/mod/mod_rewrite.html" title="English">&nbsp;en&nbsp;</a> |
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<a href="/fr/mod/mod_rewrite.html" hreflang="fr" rel="alternate" title="Fran�ais">&nbsp;fr&nbsp;</a></p>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen</div><div class="top"><a href="#page-header"><img src="/images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
8a571abb6573d916da05fc8b9f04fd944ad45803slive<script type="text/javascript"><!--//--><![CDATA[//><!--
173a6aaf8f8d2c818ab71d3781400e521051a565rbowenvar comments_shortname = 'httpd';
8a571abb6573d916da05fc8b9f04fd944ad45803slivevar comments_identifier = 'http://httpd.apache.org/docs/trunk/mod/mod_rewrite.html';
8a571abb6573d916da05fc8b9f04fd944ad45803slive(function(w, d) {
8a571abb6573d916da05fc8b9f04fd944ad45803slive if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen d.write('<div id="comments_thread"><\/div>');
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen var s = d.createElement('script');
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem s.type = 'text/javascript';
8a571abb6573d916da05fc8b9f04fd944ad45803slive s.async = true;
8a571abb6573d916da05fc8b9f04fd944ad45803slive s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
8a571abb6573d916da05fc8b9f04fd944ad45803slive (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
8a571abb6573d916da05fc8b9f04fd944ad45803slive }
8a571abb6573d916da05fc8b9f04fd944ad45803slive else {
8a571abb6573d916da05fc8b9f04fd944ad45803slive d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
8a571abb6573d916da05fc8b9f04fd944ad45803slive }
8a571abb6573d916da05fc8b9f04fd944ad45803slive})(window, document);
8a571abb6573d916da05fc8b9f04fd944ad45803slive//--><!]]></script></div><div id="footer">
8a571abb6573d916da05fc8b9f04fd944ad45803slive<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
8a571abb6573d916da05fc8b9f04fd944ad45803slive<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/quickreference.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
8a571abb6573d916da05fc8b9f04fd944ad45803sliveif (typeof(prettyPrint) !== 'undefined') {
8a571abb6573d916da05fc8b9f04fd944ad45803slive prettyPrint();
8a571abb6573d916da05fc8b9f04fd944ad45803slive}
8a571abb6573d916da05fc8b9f04fd944ad45803slive//--><!]]></script>
8a571abb6573d916da05fc8b9f04fd944ad45803slive</body></html>