mod_rewrite.html.en revision b6e6d2139d50d64fc4bbd01c4f07d7a4accfec8c
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.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>
7dc5a2d4a0c77f5bf5a95de92d68e43de7d8117anilgun<div id="page-content">
7dc5a2d4a0c77f5bf5a95de92d68e43de7d8117anilgun<div id="preamble"><h1>Apache Module mod_rewrite</h1>
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd<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
cea021a7fc2657b091df4d3b031c4254ec371dd7rbowenURLs 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>
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf<tr><th><a href="module-dict.html#SourceFile">Source�File:</a></th><td>mod_rewrite.c</td></tr></table>
f6445f3ad1c82f9398dc8edd77093cd3e20b806cnoirin<h3>Summary</h3>
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf
f6445f3ad1c82f9398dc8edd77093cd3e20b806cnoirin <p>The <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> module uses a rule-based rewriting
f6445f3ad1c82f9398dc8edd77093cd3e20b806cnoirin engine, based on a PCRE regular-expression parser, to rewrite requested URLs on
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf the fly. By default, <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> maps a URL to a filesystem
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf path. However, it can also be used to redirect one URL to another URL, or
f6445f3ad1c82f9398dc8edd77093cd3e20b806cnoirin to invoke an internal proxy fetch.</p>
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf <p><code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> provides a flexible and powerful way to
f6445f3ad1c82f9398dc8edd77093cd3e20b806cnoirin manipulate URLs using an unlimited number of rules. Each rule can have an
f6445f3ad1c82f9398dc8edd77093cd3e20b806cnoirin unlimited number of attached rule conditions, to allow you to rewrite URL
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf based on server variables, environment variables, HTTP headers, or time
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf stamps.</p>
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf <p><code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> operates on the full URL path, including the
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf path-info section. A rewrite rule can be invoked in
f6445f3ad1c82f9398dc8edd77093cd3e20b806cnoirin <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
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen sub-processing, external request redirection, or internal proxy
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen throughput.</p>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <p>Further details, discussion, and examples, are provided in the
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <a href="/rewrite/">detailed mod_rewrite documentation</a>.</p>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</div>
117c1f888a14e73cdd821dc6c23eb0411144a41cnd<div id="quickview"><h3 class="directives">Directives</h3>
117c1f888a14e73cdd821dc6c23eb0411144a41cnd<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>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<li><img alt="" src="/images/down.gif" /> <a href="#rewritemap">RewriteMap</a></li>
b41a0dbe6310c576e96b7ea6910051fd84fb06f5sf<li><img alt="" src="/images/down.gif" /> <a href="#rewriteoptions">RewriteOptions</a></li>
b41a0dbe6310c576e96b7ea6910051fd84fb06f5sf<li><img alt="" src="/images/down.gif" /> <a href="#rewriterule">RewriteRule</a></li>
7571ea383299910bead3e93e66246cb212a28d0figalic</ul>
b41a0dbe6310c576e96b7ea6910051fd84fb06f5sf<h3>Topics</h3>
b41a0dbe6310c576e96b7ea6910051fd84fb06f5sf<ul id="topics">
b41a0dbe6310c576e96b7ea6910051fd84fb06f5sf<li><img alt="" src="/images/down.gif" /> <a href="#logging">Logging</a></li>
7571ea383299910bead3e93e66246cb212a28d0figalic</ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
b41a0dbe6310c576e96b7ea6910051fd84fb06f5sf<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
b41a0dbe6310c576e96b7ea6910051fd84fb06f5sf<div class="section">
b41a0dbe6310c576e96b7ea6910051fd84fb06f5sf<h2><a name="logging" id="logging">Logging</a></h2>
b41a0dbe6310c576e96b7ea6910051fd84fb06f5sf
b41a0dbe6310c576e96b7ea6910051fd84fb06f5sf <p><code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> offers detailed logging of its actions
b41a0dbe6310c576e96b7ea6910051fd84fb06f5sf at the <code>trace1</code> to <code>trace8</code> log levels. The
b41a0dbe6310c576e96b7ea6910051fd84fb06f5sf log level can be set specifically for <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code>
b41a0dbe6310c576e96b7ea6910051fd84fb06f5sf using the <code class="directive"><a href="/mod/core.html#loglevel">LogLevel</a></code> directive: Up to
b41a0dbe6310c576e96b7ea6910051fd84fb06f5sf level <code>debug</code>, no actions are logged, while <code>trace8</code>
b41a0dbe6310c576e96b7ea6910051fd84fb06f5sf means that practically all actions are logged.</p>
b41a0dbe6310c576e96b7ea6910051fd84fb06f5sf
1f0a28764a0520e43ce3a9130e56236fd67cd568igalic <div class="note">
b41a0dbe6310c576e96b7ea6910051fd84fb06f5sf Using a high trace log level for <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code>
b41a0dbe6310c576e96b7ea6910051fd84fb06f5sf will slow down your Apache HTTP Server dramatically! Use a log
b41a0dbe6310c576e96b7ea6910051fd84fb06f5sf level higher than <code>trace2</code> only for debugging!
1e6708ac9aebbbd0ff63c2b93e6b97d50263a8bbrbowen </div>
b41a0dbe6310c576e96b7ea6910051fd84fb06f5sf
f6445f3ad1c82f9398dc8edd77093cd3e20b806cnoirin <div class="example"><h3>Example</h3><pre class="prettyprint lang-config">
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen LogLevel alert rewrite:trace3
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen </pre>
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen</div>
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen <div class="note"><h3>RewriteLog</h3>
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen <p>Those familiar with earlier versions of
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> will no doubt be looking for the
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen <code>RewriteLog</code> and <code>RewriteLogLevel</code>
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen directives. This functionality has been completely replaced by the
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen new per-module logging configuration mentioned above.
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen </p>
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen <p>To get just the <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code>-specific log
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen messages, pipe the log file through grep:</p>
9b3696c7ad70387ecd46e0f061b99d381dc392f9rbowen <div class="example"><p><code>
b41a0dbe6310c576e96b7ea6910051fd84fb06f5sf tail -f error_log|fgrep '[rewrite:'
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd </code></p></div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd </div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
635de20c16ef862bfc5b0d5f9ceb40ebeaddfdf3noirin<div class="directive-section"><h2><a name="RewriteBase" id="RewriteBase">RewriteBase</a> <a name="rewritebase" id="rewritebase">Directive</a></h2>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<table class="directive">
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets the base URL for per-directory rewrites</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteBase <em>URL-path</em></code></td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>None</code></td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>directory, .htaccess</td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
9dd0b961340554104e5b6e837ddb3101f843cc3fcovener<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
9dd0b961340554104e5b6e837ddb3101f843cc3fcovener<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
635de20c16ef862bfc5b0d5f9ceb40ebeaddfdf3noirin</table>
635de20c16ef862bfc5b0d5f9ceb40ebeaddfdf3noirin <p>The <code class="directive">RewriteBase</code> directive specifies the
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf URL prefix to be used for per-directory (htaccess)
635de20c16ef862bfc5b0d5f9ceb40ebeaddfdf3noirin <code class="directive">RewriteRule</code> directives that substitute a relative
9dd0b961340554104e5b6e837ddb3101f843cc3fcovener path.</p>
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf <p> This directive is <em>required</em> when you use a relative path
9dd0b961340554104e5b6e837ddb3101f843cc3fcovener in a substitution in per-directory (htaccess) context unless either
9dd0b961340554104e5b6e837ddb3101f843cc3fcovener of the following conditions are true:</p>
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf <ul>
25d988d92af8cf0d997aa1ebbc7cb11daa14d0becovener <li> The original request, and the substitution, are underneath the
25d988d92af8cf0d997aa1ebbc7cb11daa14d0becovener <code class="directive"><a href="/mod/core.html#documentroot">DocumentRoot</a></code>
9dd0b961340554104e5b6e837ddb3101f843cc3fcovener (as opposed to reachable by other means, such as
25d988d92af8cf0d997aa1ebbc7cb11daa14d0becovener <code class="directive"><a href="/mod/mod_alias.html#alias">Alias</a></code>).</li>
25d988d92af8cf0d997aa1ebbc7cb11daa14d0becovener <li> The <em>filesystem</em> path to the directory containing the
25d988d92af8cf0d997aa1ebbc7cb11daa14d0becovener <code class="directive">RewriteRule</code>, suffixed by the relative
635de20c16ef862bfc5b0d5f9ceb40ebeaddfdf3noirin substitution is also valid as a URL path on the server
25d988d92af8cf0d997aa1ebbc7cb11daa14d0becovener (this is rare).</li>
635de20c16ef862bfc5b0d5f9ceb40ebeaddfdf3noirin </ul>
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf<p> In the example below, <code class="directive">RewriteBase</code> is necessary
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf to avoid rewriting to http://example.com/opt/myapp-1.2.3/welcome.html
fa0f379e3845907d7c1087d885169e302239bdbbnd since the resource was not relative to the document root. This
fa0f379e3845907d7c1087d885169e302239bdbbnd misconfiguration would normally cause the server to look for an "opt"
97a9a944b5887e91042b019776c41d5dd74557aferikabele directory under the document root.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<pre class="prettyprint lang-config">
25d988d92af8cf0d997aa1ebbc7cb11daa14d0becovenerDocumentRoot /var/www/example.com
25d988d92af8cf0d997aa1ebbc7cb11daa14d0becovenerAlias /myapp /opt/myapp-1.2.3
635de20c16ef862bfc5b0d5f9ceb40ebeaddfdf3noirin&lt;Directory /opt/myapp-1.2.3&gt;
97a9a944b5887e91042b019776c41d5dd74557aferikabele RewriteEngine On
06ba4a61654b3763ad65f52283832ebf058fdf1cslive RewriteBase /myapp/
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd RewriteRule ^index\.html$ welcome.html
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd&lt;/Directory&gt;
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</pre>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
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="RewriteCond" id="RewriteCond">RewriteCond</a> <a name="rewritecond" id="rewritecond">Directive</a></h2>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<table class="directive">
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Defines a condition under which rewriting will take place
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code> RewriteCond
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <em>TestString</em> <em>CondPattern</em></code></td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
fa0f379e3845907d7c1087d885169e302239bdbbnd<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
fa0f379e3845907d7c1087d885169e302239bdbbnd<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
fa0f379e3845907d7c1087d885169e302239bdbbnd<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
fa0f379e3845907d7c1087d885169e302239bdbbnd</table>
fa0f379e3845907d7c1087d885169e302239bdbbnd <p>The <code class="directive">RewriteCond</code> directive defines a
fa0f379e3845907d7c1087d885169e302239bdbbnd rule condition. One or more <code class="directive">RewriteCond</code>
fa0f379e3845907d7c1087d885169e302239bdbbnd can precede a <code class="directive"><a href="#rewriterule">RewriteRule</a></code>
fa0f379e3845907d7c1087d885169e302239bdbbnd directive. The following rule is then only used if both
fa0f379e3845907d7c1087d885169e302239bdbbnd 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
06ba4a61654b3763ad65f52283832ebf058fdf1cslive following expanded constructs in addition to plain text:</p>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
b115299831a7b4bbec58a88d708d8536e1ecd50csf <ul>
fa0f379e3845907d7c1087d885169e302239bdbbnd <li>
fa0f379e3845907d7c1087d885169e302239bdbbnd <strong>RewriteRule backreferences</strong>: These are
b115299831a7b4bbec58a88d708d8536e1ecd50csf backreferences of the form <strong><code>$N</code></strong>
b115299831a7b4bbec58a88d708d8536e1ecd50csf (0 &lt;= N &lt;= 9). $1 to $9 provide access to the grouped
fa0f379e3845907d7c1087d885169e302239bdbbnd parts (in parentheses) of the pattern, from the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>RewriteRule</code> which is subject to the current
06ba4a61654b3763ad65f52283832ebf058fdf1cslive set of <code>RewriteCond</code> conditions. $0 provides
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem access to the whole string matched by that pattern.
b115299831a7b4bbec58a88d708d8536e1ecd50csf </li>
fa0f379e3845907d7c1087d885169e302239bdbbnd <li>
fa0f379e3845907d7c1087d885169e302239bdbbnd <strong>RewriteCond backreferences</strong>: These are
b115299831a7b4bbec58a88d708d8536e1ecd50csf backreferences of the form <strong><code>%N</code></strong>
b115299831a7b4bbec58a88d708d8536e1ecd50csf (0 &lt;= N &lt;= 9). %1 to %9 provide access to the grouped
fa0f379e3845907d7c1087d885169e302239bdbbnd parts (again, in parentheses) of the pattern, from the last matched
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>RewriteCond</code> in the current set
06ba4a61654b3763ad65f52283832ebf058fdf1cslive of conditions. %0 provides access to the whole string matched by
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem that pattern.
fa0f379e3845907d7c1087d885169e302239bdbbnd </li>
fa0f379e3845907d7c1087d885169e302239bdbbnd <li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong>RewriteMap expansions</strong>: These are
06ba4a61654b3763ad65f52283832ebf058fdf1cslive expansions of the form <strong><code>${mapname:key|default}</code></strong>.
fa0f379e3845907d7c1087d885169e302239bdbbnd See <a href="#mapfunc">the documentation for
81785f72c9d133aef57ad6b02f248345d90239aapoirier RewriteMap</a> for more details.
fa0f379e3845907d7c1087d885169e302239bdbbnd </li>
fa0f379e3845907d7c1087d885169e302239bdbbnd <li>
fa0f379e3845907d7c1087d885169e302239bdbbnd <strong>Server-Variables</strong>: These are variables of
fa0f379e3845907d7c1087d885169e302239bdbbnd the form
fa0f379e3845907d7c1087d885169e302239bdbbnd <strong><code>%{</code> <em>NAME_OF_VARIABLE</em>
fa0f379e3845907d7c1087d885169e302239bdbbnd <code>}</code></strong>
c6a2d6fa44f8698851dec5051ee3782c2913605fnd where <em>NAME_OF_VARIABLE</em> can be a string taken
06ba4a61654b3763ad65f52283832ebf058fdf1cslive from the following list:
97a9a944b5887e91042b019776c41d5dd74557aferikabele
5ae30adbe59946de742ab0cd6be3b7457471a698takashi <table>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
97a9a944b5887e91042b019776c41d5dd74557aferikabele <tr>
5ae30adbe59946de742ab0cd6be3b7457471a698takashi <th>HTTP headers:</th> <th>connection &amp; request:</th> <th />
5ae30adbe59946de742ab0cd6be3b7457471a698takashi </tr>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
97a9a944b5887e91042b019776c41d5dd74557aferikabele <tr>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <td>
97a9a944b5887e91042b019776c41d5dd74557aferikabele HTTP_USER_AGENT<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele HTTP_REFERER<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele HTTP_COOKIE<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive HTTP_FORWARDED<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive HTTP_HOST<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive HTTP_PROXY_CONNECTION<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele HTTP_ACCEPT<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele </td>
74a6de79356cd15d2e47065087785e36dd65aa41nd
97a9a944b5887e91042b019776c41d5dd74557aferikabele <td>
97a9a944b5887e91042b019776c41d5dd74557aferikabele REMOTE_ADDR<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele REMOTE_HOST<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele REMOTE_PORT<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele REMOTE_USER<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele REMOTE_IDENT<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele REQUEST_METHOD<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive SCRIPT_FILENAME<br />
5ae30adbe59946de742ab0cd6be3b7457471a698takashi PATH_INFO<br />
5ae30adbe59946de742ab0cd6be3b7457471a698takashi QUERY_STRING<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive AUTH_TYPE<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
53d2fd50ff45e7c568f0588c742a5ef9edf8e275rbowen <td />
5ae30adbe59946de742ab0cd6be3b7457471a698takashi </tr>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
97a9a944b5887e91042b019776c41d5dd74557aferikabele <tr>
5ae30adbe59946de742ab0cd6be3b7457471a698takashi <th>server internals:</th> <th>date and time:</th> <th>specials:</th>
5ae30adbe59946de742ab0cd6be3b7457471a698takashi </tr>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
97a9a944b5887e91042b019776c41d5dd74557aferikabele <tr>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <td>
97a9a944b5887e91042b019776c41d5dd74557aferikabele DOCUMENT_ROOT<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele SERVER_ADMIN<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele SERVER_NAME<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive SERVER_ADDR<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive SERVER_PORT<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive SERVER_PROTOCOL<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele SERVER_SOFTWARE<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele </td>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
97a9a944b5887e91042b019776c41d5dd74557aferikabele <td>
97a9a944b5887e91042b019776c41d5dd74557aferikabele TIME_YEAR<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele TIME_MON<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele TIME_DAY<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele TIME_HOUR<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive TIME_MIN<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive TIME_SEC<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive TIME_WDAY<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele TIME<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele </td>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
97a9a944b5887e91042b019776c41d5dd74557aferikabele <td>
97a9a944b5887e91042b019776c41d5dd74557aferikabele API_VERSION<br />
fb82af0f0cd7b58eef19c54b086131b7e1e1e749madhum THE_REQUEST<br />
4203a35c28d7c60adb7e9ef3be87aad34951c79asf REQUEST_URI<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive REQUEST_FILENAME<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive IS_SUBREQ<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive HTTPS<br />
fa0f379e3845907d7c1087d885169e302239bdbbnd REQUEST_SCHEME<br />
fa0f379e3845907d7c1087d885169e302239bdbbnd </td>
fa0f379e3845907d7c1087d885169e302239bdbbnd </tr>
cea021a7fc2657b091df4d3b031c4254ec371dd7rbowen </table>
fa0f379e3845907d7c1087d885169e302239bdbbnd
fa0f379e3845907d7c1087d885169e302239bdbbnd <p>These variables all
37ef4b86270a8e58f87aa5fe558e3e65af97991ccovener correspond to the similarly named HTTP
37ef4b86270a8e58f87aa5fe558e3e65af97991ccovener MIME-headers, C variables of the Apache HTTP Server or
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf <code>struct tm</code> fields of the Unix system.
37ef4b86270a8e58f87aa5fe558e3e65af97991ccovener Most are documented elsewhere in the Manual or in
37ef4b86270a8e58f87aa5fe558e3e65af97991ccovener the CGI specification.</p>
37ef4b86270a8e58f87aa5fe558e3e65af97991ccovener
37ef4b86270a8e58f87aa5fe558e3e65af97991ccovener <p>SERVER_NAME and SERVER_PORT depend on the values of
37ef4b86270a8e58f87aa5fe558e3e65af97991ccovener <code class="directive"><a href="/mod/core.html#usecanonicalname">UseCanonicalName</a></code> and
fa0f379e3845907d7c1087d885169e302239bdbbnd <code class="directive"><a href="/mod/core.html#usecanonicalphysicalport">UseCanonicalPhysicalPort</a></code>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive respectively.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>Those that are special to mod_rewrite include those below.</p>
fa0f379e3845907d7c1087d885169e302239bdbbnd <div class="note">
fa0f379e3845907d7c1087d885169e302239bdbbnd <dl>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dt><code>IS_SUBREQ</code></dt>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <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
cea021a7fc2657b091df4d3b031c4254ec371dd7rbowen or URIs in order to complete their tasks.</dd>
fa0f379e3845907d7c1087d885169e302239bdbbnd
fa0f379e3845907d7c1087d885169e302239bdbbnd <dt><code>API_VERSION</code></dt>
fa0f379e3845907d7c1087d885169e302239bdbbnd
cea021a7fc2657b091df4d3b031c4254ec371dd7rbowen <dd>This is the version of the Apache httpd module API
cea021a7fc2657b091df4d3b031c4254ec371dd7rbowen (the internal interface between server and
fa0f379e3845907d7c1087d885169e302239bdbbnd module) in the current httpd build, as defined in
fa0f379e3845907d7c1087d885169e302239bdbbnd include/ap_mmn.h. The module API version
06ba4a61654b3763ad65f52283832ebf058fdf1cslive corresponds to the version of Apache httpd in use (in
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the release version of Apache httpd 1.3.14, for
06ba4a61654b3763ad65f52283832ebf058fdf1cslive instance, it is 19990320:10), but is mainly of
06ba4a61654b3763ad65f52283832ebf058fdf1cslive interest to module authors.</dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dt><code>THE_REQUEST</code></dt>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf <dd>The full HTTP request line sent by the
777c17c11c2b1638f191241364e034779851d186covener browser to the server (e.g., "<code>GET
06ba4a61654b3763ad65f52283832ebf058fdf1cslive /index.html HTTP/1.1</code>"). This does not
06ba4a61654b3763ad65f52283832ebf058fdf1cslive include any additional headers sent by the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive browser. This value has not been unescaped
0844fff26cb7719e0f0a368d88544156ed6374b6sf (decoded), unlike most other variables below.</dd>
0844fff26cb7719e0f0a368d88544156ed6374b6sf
0844fff26cb7719e0f0a368d88544156ed6374b6sf <dt><code>REQUEST_URI</code></dt>
0844fff26cb7719e0f0a368d88544156ed6374b6sf
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dd>The path component of the requested URI,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive such as "/index.html". This notably excludes the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive query string which is available as as its own variable
fa0f379e3845907d7c1087d885169e302239bdbbnd named <code>QUERY_STRING</code>.</dd>
c0a201f9f0cda37f4e5829462c7e489f85bf327ccovener
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf <dt><code>REQUEST_FILENAME</code></dt>
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf <dd>The full local filesystem path to the file or
c0a201f9f0cda37f4e5829462c7e489f85bf327ccovener script matching the request, if this has already
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd been determined by the server at the time
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd <code>REQUEST_FILENAME</code> is referenced. Otherwise,
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd such as when used in virtual host context, the same
fa0f379e3845907d7c1087d885169e302239bdbbnd value as <code>REQUEST_URI</code>. Depending on the value of
fa0f379e3845907d7c1087d885169e302239bdbbnd <code class="directive"><a href="/mod/core.html#acceptpathinfo">AcceptPathInfo</a></code>, the
fa0f379e3845907d7c1087d885169e302239bdbbnd server may have only used some leading components of the
fa0f379e3845907d7c1087d885169e302239bdbbnd <code>REQUEST_URI</code> to map the request to a file.
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd </dd>
4203a35c28d7c60adb7e9ef3be87aad34951c79asf
4203a35c28d7c60adb7e9ef3be87aad34951c79asf <dt><code>HTTPS</code></dt>
4203a35c28d7c60adb7e9ef3be87aad34951c79asf
4203a35c28d7c60adb7e9ef3be87aad34951c79asf <dd>Will contain the text "on" if the connection is
4203a35c28d7c60adb7e9ef3be87aad34951c79asf using SSL/TLS, or "off" otherwise. (This variable
4203a35c28d7c60adb7e9ef3be87aad34951c79asf can be safely used regardless of whether or not
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code class="module"><a href="/mod/mod_ssl.html">mod_ssl</a></code> is loaded).</dd>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
fa0f379e3845907d7c1087d885169e302239bdbbnd <dt><code>REQUEST_SCHEME</code></dt>
fa0f379e3845907d7c1087d885169e302239bdbbnd
fa0f379e3845907d7c1087d885169e302239bdbbnd <dd>Will contain the scheme of the request (usually
4cb65c31bc681540ea623e1cb2bdd09749fb8d7esf "http" or "https"). This value can be influenced with
4cb65c31bc681540ea623e1cb2bdd09749fb8d7esf <code class="directive"><a href="/mod/core.html#servername">ServerName</a></code>.</dd>
4cb65c31bc681540ea623e1cb2bdd09749fb8d7esf
4cb65c31bc681540ea623e1cb2bdd09749fb8d7esf </dl>
fa0f379e3845907d7c1087d885169e302239bdbbnd</div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </li>
fa0f379e3845907d7c1087d885169e302239bdbbnd </ul>
fa0f379e3845907d7c1087d885169e302239bdbbnd
fa0f379e3845907d7c1087d885169e302239bdbbnd <p>If the <em>TestString</em> has the special value <code>expr</code>,
fa0f379e3845907d7c1087d885169e302239bdbbnd the <em>CondPattern</em> will be treated as an
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <a href="/expr.html">ap_expr</a>. HTTP headers referenced in the
cea021a7fc2657b091df4d3b031c4254ec371dd7rbowen expression will be added to the Vary header if the <code>novary</code>
fa0f379e3845907d7c1087d885169e302239bdbbnd flag is not given.</p>
fa0f379e3845907d7c1087d885169e302239bdbbnd
fa0f379e3845907d7c1087d885169e302239bdbbnd <p>Other things you should be aware of:</p>
fa0f379e3845907d7c1087d885169e302239bdbbnd
fa0f379e3845907d7c1087d885169e302239bdbbnd <ol>
fa0f379e3845907d7c1087d885169e302239bdbbnd <li>
fa0f379e3845907d7c1087d885169e302239bdbbnd <p>The variables SCRIPT_FILENAME and REQUEST_FILENAME
fa0f379e3845907d7c1087d885169e302239bdbbnd contain the same value - the value of the
fa0f379e3845907d7c1087d885169e302239bdbbnd <code>filename</code> field of the internal
fa0f379e3845907d7c1087d885169e302239bdbbnd <code>request_rec</code> structure of the Apache HTTP Server.
fa0f379e3845907d7c1087d885169e302239bdbbnd The first name is the commonly known CGI variable name
fa0f379e3845907d7c1087d885169e302239bdbbnd while the second is the appropriate counterpart of
fa0f379e3845907d7c1087d885169e302239bdbbnd REQUEST_URI (which contains the value of the
a4d04b8c74044c58bd4182028a1408d936c95951covener <code>uri</code> field of <code>request_rec</code>).</p>
fa0f379e3845907d7c1087d885169e302239bdbbnd <p>If a substitution occurred and the rewriting continues,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the value of both variables will be updated accordingly.</p>
fa0f379e3845907d7c1087d885169e302239bdbbnd <p>If used in per-server context (<em>i.e.</em>, before the
fa0f379e3845907d7c1087d885169e302239bdbbnd request is mapped to the filesystem) SCRIPT_FILENAME and
fa0f379e3845907d7c1087d885169e302239bdbbnd REQUEST_FILENAME cannot contain the full local filesystem
fa0f379e3845907d7c1087d885169e302239bdbbnd path since the path is unknown at this stage of processing.
cea021a7fc2657b091df4d3b031c4254ec371dd7rbowen Both variables will initially contain the value of REQUEST_URI
cea021a7fc2657b091df4d3b031c4254ec371dd7rbowen in that case. In order to obtain the full local filesystem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive path of the request in per-server context, use an URL-based
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem look-ahead <code>%{LA-U:REQUEST_FILENAME}</code> to determine
fa0f379e3845907d7c1087d885169e302239bdbbnd the final value of REQUEST_FILENAME.</p></li>
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd
fa0f379e3845907d7c1087d885169e302239bdbbnd <li>
fa0f379e3845907d7c1087d885169e302239bdbbnd <code>%{ENV:variable}</code>, where <em>variable</em> can be
fa0f379e3845907d7c1087d885169e302239bdbbnd any environment variable, is also available.
fa0f379e3845907d7c1087d885169e302239bdbbnd This is looked-up via internal
fa0f379e3845907d7c1087d885169e302239bdbbnd Apache httpd structures and (if not found there) via
fa0f379e3845907d7c1087d885169e302239bdbbnd <code>getenv()</code> from the Apache httpd server process.</li>
fa0f379e3845907d7c1087d885169e302239bdbbnd
fa0f379e3845907d7c1087d885169e302239bdbbnd <li>
fa0f379e3845907d7c1087d885169e302239bdbbnd <code>%{SSL:variable}</code>, where <em>variable</em> is the
fa0f379e3845907d7c1087d885169e302239bdbbnd name of an <a href="mod_ssl.html#envvars">SSL environment
fa0f379e3845907d7c1087d885169e302239bdbbnd variable</a>, can be used whether or not
fa0f379e3845907d7c1087d885169e302239bdbbnd <code class="module"><a href="/mod/mod_ssl.html">mod_ssl</a></code> is loaded, but will always expand to
fa0f379e3845907d7c1087d885169e302239bdbbnd the empty string if it is not. Example:
fa0f379e3845907d7c1087d885169e302239bdbbnd <code>%{SSL:SSL_CIPHER_USEKEYSIZE}</code> may expand to
fa0f379e3845907d7c1087d885169e302239bdbbnd <code>128</code>.</li>
fa0f379e3845907d7c1087d885169e302239bdbbnd
fa0f379e3845907d7c1087d885169e302239bdbbnd <li>
fa0f379e3845907d7c1087d885169e302239bdbbnd <code>%{HTTP:header}</code>, where <em>header</em> can be
fa0f379e3845907d7c1087d885169e302239bdbbnd any HTTP MIME-header name, can always be used to obtain the
fa0f379e3845907d7c1087d885169e302239bdbbnd value of a header sent in the HTTP request.
fa0f379e3845907d7c1087d885169e302239bdbbnd Example: <code>%{HTTP:Proxy-Connection}</code> is
fa0f379e3845907d7c1087d885169e302239bdbbnd the value of the HTTP header
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem ``<code>Proxy-Connection:</code>''.
fa0f379e3845907d7c1087d885169e302239bdbbnd <p>If a HTTP header is used in a condition this header is added to
fa0f379e3845907d7c1087d885169e302239bdbbnd the Vary header of the response in case the condition evaluates to
fa0f379e3845907d7c1087d885169e302239bdbbnd to true for the request. It is <strong>not</strong> added if the
fa0f379e3845907d7c1087d885169e302239bdbbnd condition evaluates to false for the request. Adding the HTTP header
fa0f379e3845907d7c1087d885169e302239bdbbnd to the Vary header of the response is needed for proper caching.</p>
fa0f379e3845907d7c1087d885169e302239bdbbnd <p>It has to be kept in mind that conditions follow a short circuit
fa0f379e3845907d7c1087d885169e302239bdbbnd logic in the case of the '<strong><code>ornext|OR</code></strong>' flag
fa0f379e3845907d7c1087d885169e302239bdbbnd so that certain conditions might not be evaluated at all.</p></li>
fa0f379e3845907d7c1087d885169e302239bdbbnd
fa0f379e3845907d7c1087d885169e302239bdbbnd <li>
fa0f379e3845907d7c1087d885169e302239bdbbnd <a id="LA-U" name="LA-U"><code>%{LA-U:variable}</code></a>
fa0f379e3845907d7c1087d885169e302239bdbbnd can be used for look-aheads which perform
fa0f379e3845907d7c1087d885169e302239bdbbnd an internal (URL-based) sub-request to determine the final
fa0f379e3845907d7c1087d885169e302239bdbbnd value of <em>variable</em>. This can be used to access
fa0f379e3845907d7c1087d885169e302239bdbbnd variable for rewriting which is not available at the current
fa0f379e3845907d7c1087d885169e302239bdbbnd stage, but will be set in a later phase.
fa0f379e3845907d7c1087d885169e302239bdbbnd <p>For instance, to rewrite according to the
fa0f379e3845907d7c1087d885169e302239bdbbnd <code>REMOTE_USER</code> variable from within the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem per-server context (<code>httpd.conf</code> file) you must
fa0f379e3845907d7c1087d885169e302239bdbbnd use <code>%{LA-U:REMOTE_USER}</code> - this
fa0f379e3845907d7c1087d885169e302239bdbbnd variable is set by the authorization phases, which come
fa0f379e3845907d7c1087d885169e302239bdbbnd <em>after</em> the URL translation phase (during which mod_rewrite
fa0f379e3845907d7c1087d885169e302239bdbbnd operates).</p>
fa0f379e3845907d7c1087d885169e302239bdbbnd <p>On the other hand, because mod_rewrite implements
06ba4a61654b3763ad65f52283832ebf058fdf1cslive its per-directory context (<code>.htaccess</code> file) via
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the Fixup phase of the API and because the authorization
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem phases come <em>before</em> this phase, you just can use
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>%{REMOTE_USER}</code> in that context.</p></li>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>%{LA-F:variable}</code> can be used to perform an internal
88f586e767b7b224bdb1a178455668a2475cfc75rbowen (filename-based) sub-request, to determine the final value
88f586e767b7b224bdb1a178455668a2475cfc75rbowen of <em>variable</em>. Most of the time, this is the same as
88f586e767b7b224bdb1a178455668a2475cfc75rbowen LA-U above.</li>
88f586e767b7b224bdb1a178455668a2475cfc75rbowen </ol>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p><em>CondPattern</em> is the condition pattern,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive a regular expression which is applied to the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive current instance of the <em>TestString</em>.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>TestString</em> is first evaluated, before being matched against
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>CondPattern</em>.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <p><em>CondPattern</em> is usually a
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>perl compatible regular expression</em>, but there is
06ba4a61654b3763ad65f52283832ebf058fdf1cslive additional syntax available to perform other useful tests against
81785f72c9d133aef57ad6b02f248345d90239aapoirier the <em>Teststring</em>:</p>
5ae30adbe59946de742ab0cd6be3b7457471a698takashi
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <ol>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>You can prefix the pattern string with a
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem '<code>!</code>' character (exclamation mark) to specify a
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong>non</strong>-matching pattern.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <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
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem compares it lexicographically to <em>TestString</em>. True if
97a9a944b5887e91042b019776c41d5dd74557aferikabele <em>TestString</em> lexicographically precedes
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <em>CondPattern</em>.</li>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>'<strong>&gt;CondPattern</strong>' (lexicographically
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem follows)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Treats the <em>CondPattern</em> as a plain string and
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem compares it lexicographically to <em>TestString</em>. True if
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>TestString</em> lexicographically follows
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>CondPattern</em>.</li>
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen <li>'<strong>=CondPattern</strong>' (lexicographically
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen equal)<br />
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen Treats the <em>CondPattern</em> as a plain string and
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen compares it lexicographically to <em>TestString</em>. True if
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen <em>TestString</em> is lexicographically equal to
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen <em>CondPattern</em> (the two strings are exactly
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen equal, character for character). If <em>CondPattern</em>
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen is <code>""</code> (two quotation marks) this
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen compares <em>TestString</em> to the empty string.</li>
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen <li>'<strong>&lt;=CondPattern</strong>' (lexicographically
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen less than or equal to)<br />
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen Treats the <em>CondPattern</em> as a plain string and
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen compares it lexicographically to <em>TestString</em>. True
88f586e767b7b224bdb1a178455668a2475cfc75rbowen if <em>TestString</em> lexicographically precedes
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen <em>CondPattern</em>, or is equal to <em>CondPattern</em>
88f586e767b7b224bdb1a178455668a2475cfc75rbowen (the two strings are equal, character for character).</li>
88f586e767b7b224bdb1a178455668a2475cfc75rbowen
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <li>'<strong>&gt;=CondPattern</strong>' (lexicographically
88f586e767b7b224bdb1a178455668a2475cfc75rbowen greater than or equal to)<br />
88f586e767b7b224bdb1a178455668a2475cfc75rbowen Treats the <em>CondPattern</em> as a plain string and
88f586e767b7b224bdb1a178455668a2475cfc75rbowen compares it lexicographically to <em>TestString</em>. True
88f586e767b7b224bdb1a178455668a2475cfc75rbowen if <em>TestString</em> lexicographically follows
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <em>CondPattern</em>, or is equal to <em>CondPattern</em>
88f586e767b7b224bdb1a178455668a2475cfc75rbowen (the two strings are equal, character for character).</li>
88f586e767b7b224bdb1a178455668a2475cfc75rbowen </ul></li>
88f586e767b7b224bdb1a178455668a2475cfc75rbowen
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <li>
88f586e767b7b224bdb1a178455668a2475cfc75rbowen You can perform integer comparisons:
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <ul>
88f586e767b7b224bdb1a178455668a2475cfc75rbowen
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <li>'<strong>-eq</strong>' (is numerically
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf <strong>eq</strong>ual to)<br />
88f586e767b7b224bdb1a178455668a2475cfc75rbowen The <em>TestString</em> is treated as an integer, and is
88f586e767b7b224bdb1a178455668a2475cfc75rbowen numerically compared to the <em>CondPattern</em>. True if
88f586e767b7b224bdb1a178455668a2475cfc75rbowen the two are numerically equal.</li>
88f586e767b7b224bdb1a178455668a2475cfc75rbowen
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <li>'<strong>-ge</strong>' (is numerically
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <strong>g</strong>reater than or <strong>e</strong>qual to)<br />
88f586e767b7b224bdb1a178455668a2475cfc75rbowen The <em>TestString</em> is treated as an integer, and is
88f586e767b7b224bdb1a178455668a2475cfc75rbowen numerically compared to the <em>CondPattern</em>. True if
88f586e767b7b224bdb1a178455668a2475cfc75rbowen the <em>TestString</em> is numerically greater than or equal
88f586e767b7b224bdb1a178455668a2475cfc75rbowen to the <em>CondPattern</em>.</li>
88f586e767b7b224bdb1a178455668a2475cfc75rbowen
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <li>'<strong>-gt</strong>' (is numerically
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <strong>g</strong>reater <strong>t</strong>han)<br />
88f586e767b7b224bdb1a178455668a2475cfc75rbowen The <em>TestString</em> is treated as an integer, and is
88f586e767b7b224bdb1a178455668a2475cfc75rbowen numerically compared to the <em>CondPattern</em>. True if
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf the <em>TestString</em> is numerically greater than
88f586e767b7b224bdb1a178455668a2475cfc75rbowen the <em>CondPattern</em>.</li>
88f586e767b7b224bdb1a178455668a2475cfc75rbowen
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <li>'<strong>-le</strong>' (is numerically
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <strong>l</strong>ess than or <strong>e</strong>qual to)<br />
88f586e767b7b224bdb1a178455668a2475cfc75rbowen The <em>TestString</em> is treated as an integer, and is
88f586e767b7b224bdb1a178455668a2475cfc75rbowen numerically compared to the <em>CondPattern</em>. True if
88f586e767b7b224bdb1a178455668a2475cfc75rbowen the <em>TestString</em> is numerically less than or equal
88f586e767b7b224bdb1a178455668a2475cfc75rbowen to the <em>CondPattern</em>. Avoid confusion with the
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <strong>-l</strong> by using the <strong>-L</strong> or
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <strong>-h</strong> variant.</li>
88f586e767b7b224bdb1a178455668a2475cfc75rbowen
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <li>'<strong>-lt</strong>' (is numerically
88f586e767b7b224bdb1a178455668a2475cfc75rbowen <strong>l</strong>ess <strong>t</strong>han)<br />
88f586e767b7b224bdb1a178455668a2475cfc75rbowen The <em>TestString</em> is treated as an integer, and is
06ba4a61654b3763ad65f52283832ebf058fdf1cslive numerically compared to the <em>CondPattern</em>. True if
97a9a944b5887e91042b019776c41d5dd74557aferikabele the <em>TestString</em> is numerically less than
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the <em>CondPattern</em>. Avoid confusion with the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <strong>-l</strong> by using the <strong>-L</strong> or
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong>-h</strong> variant.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele </ul>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </li>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>You can perform various file attribute tests:
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <ul>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <li>'<strong>-d</strong>' (is
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <strong>d</strong>irectory)<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive Treats the <em>TestString</em> as a pathname and tests
06ba4a61654b3763ad65f52283832ebf058fdf1cslive whether or not it exists, and is a directory.</li>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>'<strong>-f</strong>' (is regular
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong>f</strong>ile)<br />
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen Treats the <em>TestString</em> as a pathname and tests
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen whether or not it exists, and is a regular file.</li>
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen <li>'<strong>-F</strong>' (is existing file, via
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen subrequest)<br />
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen Checks whether or not <em>TestString</em> is a valid file,
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen accessible via all the server's currently-configured
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen access controls for that path. This uses an internal
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen subrequest to do the check, so use it with care -
88f586e767b7b224bdb1a178455668a2475cfc75rbowen it can impact your server's performance!</li>
88f586e767b7b224bdb1a178455668a2475cfc75rbowen
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen <li>'<strong>-H</strong>' (is symbolic link, bash convention)<br />
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen See <strong>-l</strong>.</li>
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen <li>'<strong>-l</strong>' (is symbolic
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen <strong>l</strong>ink)<br />
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen Treats the <em>TestString</em> as a pathname and tests
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen whether or not it exists, and is a symbolic link. May also
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen use the bash convention of <strong>-L</strong> or
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen <strong>-h</strong> if there's a possibility of confusion
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen such as when using the <strong>-lt</strong> or
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <strong>-le</strong> tests.</li>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>'<strong>-L</strong>' (is symbolic link, bash convention)<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive See <strong>-l</strong>.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
81785f72c9d133aef57ad6b02f248345d90239aapoirier <li>'<strong>-s</strong>' (is regular file, with
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <strong>s</strong>ize)<br />
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen Treats the <em>TestString</em> as a pathname and tests
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen whether or not it exists, and is a regular file with size greater
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen than zero.</li>
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen <li><p>'<strong>-U</strong>' (is existing URL, via
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen subrequest)<br />
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen Checks whether or not <em>TestString</em> is a valid URL,
3b1807171c3f06d8951da1bf23c5f51961c274bbrbowen accessible via all the server's currently-configured
06ba4a61654b3763ad65f52283832ebf058fdf1cslive access controls for that path. This uses an internal
06ba4a61654b3763ad65f52283832ebf058fdf1cslive subrequest to do the check, so use it with care -
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem it can impact your server's performance!</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p> This flag <em>only</em> returns information about things
06ba4a61654b3763ad65f52283832ebf058fdf1cslive like access control, authentication, and authorization. This flag
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>does not</em> return information about the status code the
97a9a944b5887e91042b019776c41d5dd74557aferikabele configured handler (static file, CGI, proxy, etc.) would have
06ba4a61654b3763ad65f52283832ebf058fdf1cslive returned.</p> </li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
4cb65c31bc681540ea623e1cb2bdd09749fb8d7esf <li>'<strong>-x</strong>' (has e<strong>x</strong>ecutable
4cb65c31bc681540ea623e1cb2bdd09749fb8d7esf permissions)<br />
4cb65c31bc681540ea623e1cb2bdd09749fb8d7esf Treats the <em>TestString</em> as a pathname and tests
4cb65c31bc681540ea623e1cb2bdd09749fb8d7esf whether or not it exists, and has executable permissions.
fa1092e17f0b85a610379ac564334ad879ed7dbarbowen These permissions are determined according to
fa1092e17f0b85a610379ac564334ad879ed7dbarbowen the underlying OS.</li>
fa1092e17f0b85a610379ac564334ad879ed7dbarbowen
fa1092e17f0b85a610379ac564334ad879ed7dbarbowen </ul>
fa1092e17f0b85a610379ac564334ad879ed7dbarbowen
fa1092e17f0b85a610379ac564334ad879ed7dbarbowen<div class="note"><h3>Note:</h3>
fa1092e17f0b85a610379ac564334ad879ed7dbarbowen All of these tests can
fa1092e17f0b85a610379ac564334ad879ed7dbarbowen also be prefixed by an exclamation mark ('!') to
fa1092e17f0b85a610379ac564334ad879ed7dbarbowen negate their meaning.
fa1092e17f0b85a610379ac564334ad879ed7dbarbowen</div>
fa1092e17f0b85a610379ac564334ad879ed7dbarbowen </li>
4cb65c31bc681540ea623e1cb2bdd09749fb8d7esf
4cb65c31bc681540ea623e1cb2bdd09749fb8d7esf <li>
5ae30adbe59946de742ab0cd6be3b7457471a698takashi <p>If the <em>TestString</em> has the special value <code>expr</code>, the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <em>CondPattern</em> will be treated as an
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <a href="/expr.html">ap_expr</a>.</p>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p>
22d5d84393d960a2027f472036f3fee15d7dbce9nd In the below example, <code>-strmatch</code> is used to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive compare the <code>REFERER</code> against the site hostname,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive to block unwanted hotlinking.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </p>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
81785f72c9d133aef57ad6b02f248345d90239aapoirier <pre class="prettyprint lang-config">
5ae30adbe59946de742ab0cd6be3b7457471a698takashi RewriteCond expr "! %{HTTP_REFERER} -strmatch '*://%{HTTP_HOST}/*'"<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive RewriteRule ^/images - [F]
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </pre>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>You can also set special flags for
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>CondPattern</em> by appending
97a9a944b5887e91042b019776c41d5dd74557aferikabele <strong><code>[</code><em>flags</em><code>]</code></strong>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem as the third argument to the <code>RewriteCond</code>
81785f72c9d133aef57ad6b02f248345d90239aapoirier directive, where <em>flags</em> is a comma-separated list of any of the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive following flags:
97a9a944b5887e91042b019776c41d5dd74557aferikabele
025069f3f8c6b59e730a72c229329dfad5a28424rbowen <ul>
025069f3f8c6b59e730a72c229329dfad5a28424rbowen <li>'<strong><code>nocase|NC</code></strong>'
025069f3f8c6b59e730a72c229329dfad5a28424rbowen (<strong>n</strong>o <strong>c</strong>ase)<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive This makes the test case-insensitive - differences
97a9a944b5887e91042b019776c41d5dd74557aferikabele between 'A-Z' and 'a-z' are ignored, both in the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive expanded <em>TestString</em> and the <em>CondPattern</em>.
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem This flag is effective only for comparisons between
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <em>TestString</em> and <em>CondPattern</em>. It has no
06ba4a61654b3763ad65f52283832ebf058fdf1cslive effect on filesystem and subrequest checks.</li>
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl <li>
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl '<strong><code>ornext|OR</code></strong>'
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl (<strong>or</strong> next condition)<br />
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl Use this to combine rule conditions with a local OR
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl instead of the implicit AND. Typical example:
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl<pre class="prettyprint lang-config">
9335f6d807d76d60e54af4ededdebebddb3e3d13noodlRewriteCond %{REMOTE_HOST} ^host1 [OR]
9335f6d807d76d60e54af4ededdebebddb3e3d13noodlRewriteCond %{REMOTE_HOST} ^host2 [OR]
06ba4a61654b3763ad65f52283832ebf058fdf1csliveRewriteCond %{REMOTE_HOST} ^host3
22d5d84393d960a2027f472036f3fee15d7dbce9ndRewriteRule ...some special stuff for any of these hosts...
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem</pre>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive Without this flag you would have to write the condition/rule
06ba4a61654b3763ad65f52283832ebf058fdf1cslive pair three times.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>'<strong><code>novary|NV</code></strong>'
97a9a944b5887e91042b019776c41d5dd74557aferikabele (<strong>n</strong>o <strong>v</strong>ary)<br />
7171511e7e2c17e9b54cc34dc247266b70138d6crbowen If a HTTP header is used in the condition, this flag prevents
06ba4a61654b3763ad65f52283832ebf058fdf1cslive this header from being added to the Vary header of the response. <br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive Using this flag might break proper caching of the response if
7171511e7e2c17e9b54cc34dc247266b70138d6crbowen the representation of this response varies on the value of this header.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive So this flag should be only used if the meaning of the Vary header
06ba4a61654b3763ad65f52283832ebf058fdf1cslive is well understood.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </li>
97a9a944b5887e91042b019776c41d5dd74557aferikabele </ul>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </li>
81785f72c9d133aef57ad6b02f248345d90239aapoirier </ol>
5ae30adbe59946de742ab0cd6be3b7457471a698takashi
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p><strong>Example:</strong></p>
5ae30adbe59946de742ab0cd6be3b7457471a698takashi
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p>To rewrite the Homepage of a site according to the
81785f72c9d133aef57ad6b02f248345d90239aapoirier ``<code>User-Agent:</code>'' header of the request, you can
5ae30adbe59946de742ab0cd6be3b7457471a698takashi use the following: </p>
5ae30adbe59946de742ab0cd6be3b7457471a698takashi
5ae30adbe59946de742ab0cd6be3b7457471a698takashi<pre class="prettyprint lang-config">
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluemRewriteCond %{HTTP_USER_AGENT} (iPhone|Blackberry|Android)
06ba4a61654b3763ad65f52283832ebf058fdf1csliveRewriteRule ^/$ /homepage.mobile.html [L]
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4ndRewriteRule ^/$ /homepage.std.html [L]
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</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
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd there are many other mobile platforms), the mobile version of
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd the homepage is served. Otherwise, the standard page is served.
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd </p>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
81785f72c9d133aef57ad6b02f248345d90239aapoirier</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="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>
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>
4c36c711036219c80d5517d35be68a4769c15291slive</table>
4c36c711036219c80d5517d35be68a4769c15291slive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>The <code class="directive">RewriteEngine</code> directive enables or
4c36c711036219c80d5517d35be68a4769c15291slive disables the runtime rewriting engine. If it is set to
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <code>off</code> this module does no runtime processing at
fc9f416faa11879811f17d6efadedbf81cfd52a1covener all. It does not even update the <code>SCRIPT_URx</code>
fc9f416faa11879811f17d6efadedbf81cfd52a1covener environment variables.</p>
fc9f416faa11879811f17d6efadedbf81cfd52a1covener
fc9f416faa11879811f17d6efadedbf81cfd52a1covener <p>Use this directive to disable rules in a particular contact,
fc9f416faa11879811f17d6efadedbf81cfd52a1covener rather than commenting out all the <code class="directive"><a href="#rewriterule">RewriteRule</a></code> directives.</p>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <p>Note that rewrite configurations are not
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd inherited by virtual hosts. This means that you need to have a
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <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
cea021a7fc2657b091df4d3b031c4254ec371dd7rbowen</div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<div class="directive-section"><h2><a name="RewriteMap" id="RewriteMap">RewriteMap</a> <a name="rewritemap" id="rewritemap">Directive</a></h2>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<table class="directive">
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Defines a mapping function for key-lookup</td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<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
97a9a944b5887e91042b019776c41d5dd74557aferikabele 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>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p class="indent">
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong><code>${</code> <em>MapName</em> <code>:</code>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>LookupKey</em> <code>}</code><br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>${</code> <em>MapName</em> <code>:</code>
7992de7f9e82ab86effe3dcc5279fb959f6c398dcovener <em>LookupKey</em> <code>|</code> <em>DefaultValue</em>
7992de7f9e82ab86effe3dcc5279fb959f6c398dcovener <code>}</code></strong>
7992de7f9e82ab86effe3dcc5279fb959f6c398dcovener </p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen <p>When such a construct occurs, the map <em>MapName</em> is
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen consulted and the key <em>LookupKey</em> is looked-up. If the
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen key is found, the map-function construct is substituted by
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen <em>SubstValue</em>. If the key is not found then it is
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen substituted by <em>DefaultValue</em> or by the empty string
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen if no <em>DefaultValue</em> was specified. Empty values
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen behave as if the key was absent, therefore it is not possible
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen to distinguish between empty-valued keys and absent keys.</p>
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen <p>For example, you might define a
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen <code class="directive">RewriteMap</code> as:</p>
8ac3ff7008df949c096f9cd8f769c7893594f61fnd
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen <pre class="prettyprint lang-config">
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen RewriteMap examplemap txt:/path/to/file/map.txt
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </pre>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
790a477f6ce41161c4173c1e5080a1f569976a1erbowen <p>You would then be able to use this map in a
790a477f6ce41161c4173c1e5080a1f569976a1erbowen <code class="directive">RewriteRule</code> as follows:</p>
790a477f6ce41161c4173c1e5080a1f569976a1erbowen
790a477f6ce41161c4173c1e5080a1f569976a1erbowen <pre class="prettyprint lang-config">
790a477f6ce41161c4173c1e5080a1f569976a1erbowen RewriteRule ^/ex/(.*) ${examplemap:$1}
790a477f6ce41161c4173c1e5080a1f569976a1erbowen </pre>
790a477f6ce41161c4173c1e5080a1f569976a1erbowen
790a477f6ce41161c4173c1e5080a1f569976a1erbowen
790a477f6ce41161c4173c1e5080a1f569976a1erbowen <p>The following combinations for <em>MapType</em> and
790a477f6ce41161c4173c1e5080a1f569976a1erbowen <em>MapSource</em> can be used:</p>
790a477f6ce41161c4173c1e5080a1f569976a1erbowen
0a3142725875ea286597e083547d34d98f8c1f2drbowen <dl>
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf
790a477f6ce41161c4173c1e5080a1f569976a1erbowen <dt>txt</dt>
0a3142725875ea286597e083547d34d98f8c1f2drbowen <dd>A plain text file containing space-separated key-value
790a477f6ce41161c4173c1e5080a1f569976a1erbowen pairs, one per line. (<a href="/rewrite/rewritemap.html#txt">Details ...</a>)</dd>
790a477f6ce41161c4173c1e5080a1f569976a1erbowen
0a3142725875ea286597e083547d34d98f8c1f2drbowen <dt>rnd</dt>
790a477f6ce41161c4173c1e5080a1f569976a1erbowen <dd>Randomly selects an entry from a plain text file (<a href="/rewrite/rewritemap.html#rnd">Details ...</a>)</dd>
790a477f6ce41161c4173c1e5080a1f569976a1erbowen
790a477f6ce41161c4173c1e5080a1f569976a1erbowen <dt>dbm</dt>
790a477f6ce41161c4173c1e5080a1f569976a1erbowen <dd>Looks up an entry in a dbm file containing name, value
790a477f6ce41161c4173c1e5080a1f569976a1erbowen pairs. Hash is constructed from a plain text file format using
790a477f6ce41161c4173c1e5080a1f569976a1erbowen the <code><a href="/programs/httxt2dbm.html">httxt2dbm</a></code>
790a477f6ce41161c4173c1e5080a1f569976a1erbowen utility. (<a href="/rewrite/rewritemap.html#dbm">Details ...</a>)</dd>
790a477f6ce41161c4173c1e5080a1f569976a1erbowen
790a477f6ce41161c4173c1e5080a1f569976a1erbowen <dt>int</dt>
790a477f6ce41161c4173c1e5080a1f569976a1erbowen <dd>One of the four available internal functions provided by
0a3142725875ea286597e083547d34d98f8c1f2drbowen <code>RewriteMap</code>: toupper, tolower, escape or
0a3142725875ea286597e083547d34d98f8c1f2drbowen unescape. (<a href="/rewrite/rewritemap.html#int">Details ...</a>)</dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <dt>prg</dt>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <dd>Calls an external program or script to process the
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd rewriting. (<a href="/rewrite/rewritemap.html#prg">Details ...</a>)</dd>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <dt>dbd or fastdbd</dt>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <dd>A SQL SELECT statement to be performed to look up the
0203b896e484dfb877111aceffb812401d0f216and rewrite target. (<a href="/rewrite/rewritemap.html#dbd">Details ...</a>)</dd>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd </dl>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <p>Further details, and numerous examples, may be found in the <a href="/rewrite/rewritemap.html">RewriteMap HowTo</a></p>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
844def494f17cb1ab0983427d5c3939e1a03ff8cnd
0203b896e484dfb877111aceffb812401d0f216and</div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<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>
81785f72c9d133aef57ad6b02f248345d90239aapoirier<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteOptions <var>Options</var></code></td></tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<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>
0203b896e484dfb877111aceffb812401d0f216and<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
8681ae721fdee17238ebfb7edaeb5c3edc9f1a33nd<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
1437d609a6e92c3f32dfdb0d63fce4fd2243fa0frbowen</table>
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf
1437d609a6e92c3f32dfdb0d63fce4fd2243fa0frbowen <p>The <code class="directive">RewriteOptions</code> directive sets some
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem special options for the current per-server or per-directory
0203b896e484dfb877111aceffb812401d0f216and configuration. The <em>Option</em> string can currently
0203b896e484dfb877111aceffb812401d0f216and only be one of the following:</p>
0203b896e484dfb877111aceffb812401d0f216and
a4d04b8c74044c58bd4182028a1408d936c95951covener <dl>
a4d04b8c74044c58bd4182028a1408d936c95951covener <dt><code>Inherit</code></dt>
a4d04b8c74044c58bd4182028a1408d936c95951covener <dd>
a4d04b8c74044c58bd4182028a1408d936c95951covener
a4d04b8c74044c58bd4182028a1408d936c95951covener <p>This forces the current configuration to inherit the
a4d04b8c74044c58bd4182028a1408d936c95951covener configuration of the parent. In per-virtual-server context,
a4d04b8c74044c58bd4182028a1408d936c95951covener this means that the maps, conditions and rules of the main
a4d04b8c74044c58bd4182028a1408d936c95951covener server are inherited. In per-directory context this means
1437d609a6e92c3f32dfdb0d63fce4fd2243fa0frbowen that conditions and rules of the parent directory's
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf <code>.htaccess</code> configuration or
1437d609a6e92c3f32dfdb0d63fce4fd2243fa0frbowen <code class="directive"><a href="/mod/core.html#directory">&lt;Directory&gt;</a></code>
1437d609a6e92c3f32dfdb0d63fce4fd2243fa0frbowen sections are inherited. The inherited rules are virtually copied
1437d609a6e92c3f32dfdb0d63fce4fd2243fa0frbowen to the section where this directive is being used. If used in
1437d609a6e92c3f32dfdb0d63fce4fd2243fa0frbowen combination with local rules, the inherited rules are copied behind
1437d609a6e92c3f32dfdb0d63fce4fd2243fa0frbowen the local rules. The position of this directive - below or above
8681ae721fdee17238ebfb7edaeb5c3edc9f1a33nd of local rules - has no influence on this behavior. If local
8681ae721fdee17238ebfb7edaeb5c3edc9f1a33nd rules forced the rewriting to stop, the inherited rules won't
8681ae721fdee17238ebfb7edaeb5c3edc9f1a33nd be processed.</p>
8681ae721fdee17238ebfb7edaeb5c3edc9f1a33nd
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf <div class="warning">
8681ae721fdee17238ebfb7edaeb5c3edc9f1a33nd Rules inherited from the parent scope are applied
8681ae721fdee17238ebfb7edaeb5c3edc9f1a33nd <strong>after</strong> rules specified in the child scope.
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf </div>
0203b896e484dfb877111aceffb812401d0f216and </dd>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
8681ae721fdee17238ebfb7edaeb5c3edc9f1a33nd <dt><code>InheritBefore</code></dt>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <dd>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <p> Like <code>Inherit</code> above, but the rules from the parent scope
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd are applied <strong>before</strong> rules specified in the child scope.
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd Available in Apache HTTP Server 2.3.10 and later.</p>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd </dd>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
96147932f199be4ad038778e702c13a2f79051c0slive <dt><code>AllowNoSlash</code></dt>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <dd>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <p>By default, <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> will ignore URLs that map to a
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd directory on disk but lack a trailing slash, in the expectation that
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd the <code class="module"><a href="/mod/mod_dir.html">mod_dir</a></code> module will issue the client with a redirect to
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd the canonical URL with a trailing slash.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
81785f72c9d133aef57ad6b02f248345d90239aapoirier <p>When the <code class="directive"><a href="/mod/mod_dir.html#directoryslash">DirectorySlash</a></code> directive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem is set to off, the <code>AllowNoSlash</code> option can be enabled to ensure
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem that rewrite rules are no longer ignored. This option makes it possible to
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem apply rewrite rules within .htaccess files that match the directory without
06ba4a61654b3763ad65f52283832ebf058fdf1cslive a trailing slash, if so desired. Available in Apache HTTP Server 2.4.0 and
630c456b6461158be6cc5c5483735e27b13b4ad5nd later.</p>
630c456b6461158be6cc5c5483735e27b13b4ad5nd </dd>
37ef4b86270a8e58f87aa5fe558e3e65af97991ccovener
8c8c2e71c84babf0e8c4b35819c7c5b3be014cfenoodl <dt><code>AllowAnyURI</code></dt>
8c8c2e71c84babf0e8c4b35819c7c5b3be014cfenoodl <dd>
8c8c2e71c84babf0e8c4b35819c7c5b3be014cfenoodl
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>When <code class="directive"><a href="#rewriterule">RewriteRule</a></code>
96147932f199be4ad038778e702c13a2f79051c0slive is used in <code>VirtualHost</code> or server context with
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf version 2.2.22 or later of httpd, <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code>
9560125bd44b9d138cb67884b1884401edb1eb85covener will only process the rewrite rules if the request URI is a <a href="directive-dict.html#Syntax">URL-path</a>. This avoids
9560125bd44b9d138cb67884b1884401edb1eb85covener some security issues where particular rules could allow
9560125bd44b9d138cb67884b1884401edb1eb85covener "surprising" pattern expansions (see <a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-3368">CVE-2011-3368</a>
9560125bd44b9d138cb67884b1884401edb1eb85covener and <a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-4317">CVE-2011-4317</a>).
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf To lift the restriction on matching a URL-path, the
9560125bd44b9d138cb67884b1884401edb1eb85covener <code>AllowAnyURI</code> option can be enabled, and
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> will apply the rule set to any
9560125bd44b9d138cb67884b1884401edb1eb85covener request URI string, regardless of whether that string matches
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf the URL-path grammar required by the HTTP specification.</p>
e619b7228ac42d9c70d6a5f02d808b0d2880080ccovener
96147932f199be4ad038778e702c13a2f79051c0slive <div class="warning">
96147932f199be4ad038778e702c13a2f79051c0slive <h3>Security Warning</h3>
9560125bd44b9d138cb67884b1884401edb1eb85covener
e619b7228ac42d9c70d6a5f02d808b0d2880080ccovener <p>Enabling this option will make the server vulnerable to
9560125bd44b9d138cb67884b1884401edb1eb85covener security issues if used with rewrite rules which are not
9560125bd44b9d138cb67884b1884401edb1eb85covener carefully authored. It is <strong>strongly recommended</strong>
9560125bd44b9d138cb67884b1884401edb1eb85covener that this option is not used. In particular, beware of input
9560125bd44b9d138cb67884b1884401edb1eb85covener strings containing the '<code>@</code>' character which could
9dd0b961340554104e5b6e837ddb3101f843cc3fcovener change the interpretation of the transformed URI, as per the
9560125bd44b9d138cb67884b1884401edb1eb85covener above CVE names.</p>
9560125bd44b9d138cb67884b1884401edb1eb85covener </div>
9560125bd44b9d138cb67884b1884401edb1eb85covener </dd>
9560125bd44b9d138cb67884b1884401edb1eb85covener
9560125bd44b9d138cb67884b1884401edb1eb85covener <dt><code>MergeBase</code></dt>
9560125bd44b9d138cb67884b1884401edb1eb85covener <dd>
9560125bd44b9d138cb67884b1884401edb1eb85covener
9560125bd44b9d138cb67884b1884401edb1eb85covener <p>With this option, the value of <code class="directive"><a href="#rewritebase">RewriteBase</a></code> is copied from where it's explicitly defined
9560125bd44b9d138cb67884b1884401edb1eb85covener into any sub-directory or sub-location that doesn't define its own
9560125bd44b9d138cb67884b1884401edb1eb85covener <code class="directive"><a href="#rewritebase">RewriteBase</a></code>. Available in
9560125bd44b9d138cb67884b1884401edb1eb85covener Apache HTTP Server 2.5 and later only.</p>
9560125bd44b9d138cb67884b1884401edb1eb85covener </dd>
9560125bd44b9d138cb67884b1884401edb1eb85covener </dl>
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf</div>
9560125bd44b9d138cb67884b1884401edb1eb85covener<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
9560125bd44b9d138cb67884b1884401edb1eb85covener<div class="directive-section"><h2><a name="RewriteRule" id="RewriteRule">RewriteRule</a> <a name="rewriterule" id="rewriterule">Directive</a></h2>
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf<table class="directive">
9560125bd44b9d138cb67884b1884401edb1eb85covener<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Defines rules for the rewriting engine</td></tr>
9560125bd44b9d138cb67884b1884401edb1eb85covener<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteRule
9560125bd44b9d138cb67884b1884401edb1eb85covener <em>Pattern</em> <em>Substitution</em> [<em>flags</em>]</code></td></tr>
9560125bd44b9d138cb67884b1884401edb1eb85covener<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
9dd0b961340554104e5b6e837ddb3101f843cc3fcovener<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
9560125bd44b9d138cb67884b1884401edb1eb85covener<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
9560125bd44b9d138cb67884b1884401edb1eb85covener<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
9560125bd44b9d138cb67884b1884401edb1eb85covener</table>
9560125bd44b9d138cb67884b1884401edb1eb85covener <p>The <code class="directive">RewriteRule</code> directive is the real
9560125bd44b9d138cb67884b1884401edb1eb85covener rewriting workhorse. The directive can occur more than once,
96147932f199be4ad038778e702c13a2f79051c0slive with each instance defining a single rewrite rule. The
96147932f199be4ad038778e702c13a2f79051c0slive order in which these rules are defined is important - this is the order
70f2730533c8592263435354e66d9dbaf4d6361bslive in which they will be applied at run-time.</p>
70f2730533c8592263435354e66d9dbaf4d6361bslive
1093a264c81aa1041581ab059905fb8f7cdfc5e2rbowen <p><a id="patterns" name="patterns"><em>Pattern</em></a> is
70f2730533c8592263435354e66d9dbaf4d6361bslive a perl compatible <a id="regexp" name="regexp">regular
06ba4a61654b3763ad65f52283832ebf058fdf1cslive expression</a>. On the first RewriteRule, it is matched against
5ae30adbe59946de742ab0cd6be3b7457471a698takashi the (%-decoded) <a href="directive-dict.html#Syntax">URL-path</a> (or
81785f72c9d133aef57ad6b02f248345d90239aapoirier <a href="directive-dict.html#Syntax">file-path</a>, depending
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem on the context) of the request. Subsequent patterns are matched against the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive 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,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive The <em>Pattern</em> will initially be matched against the part of the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem URL after the hostname and port, and before the query string (e.g. "/app1/index.html").</p>
81785f72c9d133aef57ad6b02f248345d90239aapoirier
81785f72c9d133aef57ad6b02f248345d90239aapoirier <p>In <code class="directive"><a href="/mod/core.html#directory">Directory</a></code> and htaccess context,
81785f72c9d133aef57ad6b02f248345d90239aapoirier the <em>Pattern</em> will initially be matched against the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <em>filesystem</em> path, after removing the prefix that led the server
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem to the current <code class="directive">RewriteRule</code> (e.g. "app1/index.html"
97a9a944b5887e91042b019776c41d5dd74557aferikabele or "index.html" depending on where the directives are defined).</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
96147932f199be4ad038778e702c13a2f79051c0slive <p>If you wish to match against the hostname, port, or query string, use a
96147932f199be4ad038778e702c13a2f79051c0slive <code class="directive"><a href="#rewritecond">RewriteCond</a></code> with the
96147932f199be4ad038778e702c13a2f79051c0slive <code>%{HTTP_HOST}</code>, <code>%{SERVER_PORT}</code>, or
96147932f199be4ad038778e702c13a2f79051c0slive <code>%{QUERY_STRING}</code> variables respectively.</p>
96147932f199be4ad038778e702c13a2f79051c0slive
96147932f199be4ad038778e702c13a2f79051c0slive</div>
96147932f199be4ad038778e702c13a2f79051c0slive
96147932f199be4ad038778e702c13a2f79051c0slive<div class="note"><h3>Per-directory Rewrites</h3>
96147932f199be4ad038778e702c13a2f79051c0slive<ul>
96147932f199be4ad038778e702c13a2f79051c0slive<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
96147932f199be4ad038778e702c13a2f79051c0slivecomplexity.</li>
96147932f199be4ad038778e702c13a2f79051c0slive
81785f72c9d133aef57ad6b02f248345d90239aapoirier<li>To enable the rewrite engine in this context, you need to set
96147932f199be4ad038778e702c13a2f79051c0slive"<code>RewriteEngine On</code>" <strong>and</strong>
96147932f199be4ad038778e702c13a2f79051c0slive"<code>Options FollowSymLinks</code>" must be enabled. If your
96147932f199be4ad038778e702c13a2f79051c0sliveadministrator has disabled override of <code>FollowSymLinks</code> for
96147932f199be4ad038778e702c13a2f79051c0slivea user's directory, then you cannot use the rewrite engine. This
e00def5e805da9a73b72ad25dac664f0c8c36c2endrestriction is required for security reasons.</li>
96147932f199be4ad038778e702c13a2f79051c0slive
96147932f199be4ad038778e702c13a2f79051c0slive<li>When using the rewrite engine in <code>.htaccess</code> files the
96147932f199be4ad038778e702c13a2f79051c0sliveper-directory prefix (which always is the same for a specific
96147932f199be4ad038778e702c13a2f79051c0slivedirectory) is automatically <em>removed</em> for the RewriteRule pattern matching
96147932f199be4ad038778e702c13a2f79051c0sliveand automatically <em>added</em> after any relative (not starting with a
96147932f199be4ad038778e702c13a2f79051c0sliveslash or protocol name) substitution encounters the end of a rule set.
96147932f199be4ad038778e702c13a2f79051c0sliveSee the <code class="directive"><a href="#rewritebase">RewriteBase</a></code>
96147932f199be4ad038778e702c13a2f79051c0slivedirective for more information regarding what prefix will be added back to
96147932f199be4ad038778e702c13a2f79051c0sliverelative substitutions.</li>
96147932f199be4ad038778e702c13a2f79051c0slive
96147932f199be4ad038778e702c13a2f79051c0slive<li> If you wish to match against the full URL-path in a per-directory
96147932f199be4ad038778e702c13a2f79051c0slive(htaccess) RewriteRule, use the <code>%{REQUEST_URI}</code> variable in
96147932f199be4ad038778e702c13a2f79051c0slivea <code class="directive">RewriteCond</code>.</li>
96147932f199be4ad038778e702c13a2f79051c0slive
96147932f199be4ad038778e702c13a2f79051c0slive<li>The removed prefix always ends with a slash, meaning the matching occurs against a string which
96147932f199be4ad038778e702c13a2f79051c0slive<em>never</em> has a leading slash. Therefore, a <em>Pattern</em> with <code>^/</code> never
96147932f199be4ad038778e702c13a2f79051c0slivematches in per-directory context.</li>
96147932f199be4ad038778e702c13a2f79051c0slive
96147932f199be4ad038778e702c13a2f79051c0slive<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
96147932f199be4ad038778e702c13a2f79051c0sliveshould never be necessary and is unsupported.</li>
96147932f199be4ad038778e702c13a2f79051c0slive</ul>
96147932f199be4ad038778e702c13a2f79051c0slive</div>
96147932f199be4ad038778e702c13a2f79051c0slive
96147932f199be4ad038778e702c13a2f79051c0slive <p>For some hints on <a class="glossarylink" href="/glossary.html#regex" title="see glossary">regular
96147932f199be4ad038778e702c13a2f79051c0slive expressions</a>, see
96147932f199be4ad038778e702c13a2f79051c0slive the <a href="/rewrite/intro.html#regex">mod_rewrite
96147932f199be4ad038778e702c13a2f79051c0slive Introduction</a>.</p>
96147932f199be4ad038778e702c13a2f79051c0slive
96147932f199be4ad038778e702c13a2f79051c0slive <p>In mod_rewrite, the NOT character
96147932f199be4ad038778e702c13a2f79051c0slive ('<code>!</code>') is also available as a possible pattern
06ba4a61654b3763ad65f52283832ebf058fdf1cslive prefix. This enables you to negate a pattern; to say, for instance:
06ba4a61654b3763ad65f52283832ebf058fdf1cslive ``<em>if the current URL does <strong>NOT</strong> match this
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem pattern</em>''. This can be used for exceptional cases, where
06ba4a61654b3763ad65f52283832ebf058fdf1cslive it is easier to match the negative pattern, or as a last
06ba4a61654b3763ad65f52283832ebf058fdf1cslive default rule.</p>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<div class="note"><h3>Note</h3>
06ba4a61654b3763ad65f52283832ebf058fdf1csliveWhen using the NOT character to negate a pattern, you cannot include
06ba4a61654b3763ad65f52283832ebf058fdf1cslivegrouped wildcard parts in that pattern. This is because, when the
06ba4a61654b3763ad65f52283832ebf058fdf1cslivepattern does NOT match (ie, the negation matches), there are no
06ba4a61654b3763ad65f52283832ebf058fdf1cslivecontents for the groups. Thus, if negated patterns are used, you
06ba4a61654b3763ad65f52283832ebf058fdf1cslivecannot use <code>$N</code> in the substitution string!
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
96147932f199be4ad038778e702c13a2f79051c0slive <p>The <a id="rhs" name="rhs"><em>Substitution</em></a> of a
81785f72c9d133aef57ad6b02f248345d90239aapoirier rewrite rule is the string that replaces the original URL-path that
5ae30adbe59946de742ab0cd6be3b7457471a698takashi was matched by <em>Pattern</em>. The <em>Substitution</em> may
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem be a:</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dl>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dt>file-system path</dt>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <dd>Designates the location on the file-system of the resource
06ba4a61654b3763ad65f52283832ebf058fdf1cslive to be delivered to the client. Substitutions are only
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem treated as a file-system path when the rule is configured in
81785f72c9d133aef57ad6b02f248345d90239aapoirier server (virtualhost) context and the first component of the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem path in the substitution exists in the file-system</dd>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dt>URL-path</dt>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <dd>A <code class="directive"><a href="/mod/core.html#documentroot">DocumentRoot</a></code>-relative path to the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem 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
81785f72c9d133aef57ad6b02f248345d90239aapoirier 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
70373b9ee042e7b3be82eee14b17f510fffdacc9slive resulting URL-path, use the <code>[PT]</code> flag as
81785f72c9d133aef57ad6b02f248345d90239aapoirier described below.</dd>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dt>Absolute URL</dt>
81785f72c9d133aef57ad6b02f248345d90239aapoirier
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <dd>If an absolute URL is specified,
545fa9d9188f1ae00e785e784f23e1f0a62b7c25sf <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> checks to see whether the
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen hostname matches the current host. If it does, the scheme and
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen hostname are stripped out and the resulting path is treated as
545fa9d9188f1ae00e785e784f23e1f0a62b7c25sf a URL-path. Otherwise, an external redirect is performed for
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen the given URL. To force an external redirect back to the
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen current host, see the <code>[R]</code> flag below.</dd>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <dt><code>-</code> (dash)</dt>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <dd>A dash indicates that no substitution should be performed
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen (the existing path is passed through untouched). This is used
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen when a flag (see below) needs to be applied without changing
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen the path.</dd>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </dl>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <p>In addition to plain text, the <em>Substitution</em> string can include</p>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf <ol>
65a3fea479371d1bd7a25f39e95c00fd38c02ed9rbowen <li>back-references (<code>$N</code>) to the RewriteRule
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen pattern</li>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <li>back-references (<code>%N</code>) to the last matched
590742c95db6e12a810030a36b295271f3228e31rbowen RewriteCond pattern</li>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf <li>server-variables as in rule condition test-strings
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen (<code>%{VARNAME}</code>)</li>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <li><a href="#mapfunc">mapping-function</a> calls
4cb65c31bc681540ea623e1cb2bdd09749fb8d7esf (<code>${mapname:key|default}</code>)</li>
39d67f66729a7008c1e73d65a81e778ce819a227rjung </ol>
4cb65c31bc681540ea623e1cb2bdd09749fb8d7esf
4cb65c31bc681540ea623e1cb2bdd09749fb8d7esf <p>Back-references are identifiers of the form
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <code>$</code><strong>N</strong>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen (<strong>N</strong>=0..9), which will be replaced
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen by the contents of the <strong>N</strong>th group of the
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen matched <em>Pattern</em>. The server-variables are the same
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen as for the <em>TestString</em> of a <code>RewriteCond</code>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen directive. The mapping-functions come from the
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <code>RewriteMap</code> directive and are explained there.
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen These three types of variables are expanded in the order above.</p>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <p>Rewrite rules are applied to the results of previous rewrite
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen rules, in the order in which they are defined
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen 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
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen replaced</strong> by the <em>Substitution</em> and the
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen rewriting process continues until all rules have been applied,
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen or it is explicitly terminated by an
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <a href="/rewrite/flags.html#flag_l"><code><strong>L</strong></code> flag</a>,
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen or other flag which implies immediate termination, such as
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <code><strong>END</strong></code> or
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <code><strong>F</strong></code>.</p>
1e6708ac9aebbbd0ff63c2b93e6b97d50263a8bbrbowen
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <div class="note"><h3>Modifying the Query String</h3>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <p>By default, the query string is passed through unchanged. You
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen can, however, create URLs in the substitution string containing
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen a query string part. Simply use a question mark inside the
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen substitution string to indicate that the following text should
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen be re-injected into the query string. When you want to erase an
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen existing query string, end the substitution string with just a
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen question mark. To combine new and old query strings, use the
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <code>[QSA]</code> flag.</p>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </div>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <p>Additionally you can set special <a name="rewriteflags" id="rewriteflags">actions</a> to be performed by
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen appending <strong><code>[</code><em>flags</em><code>]</code></strong>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen as the third argument to the <code>RewriteRule</code>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen directive. <em>Flags</em> is a comma-separated list, surround by square
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen brackets, of any of the flags in the following table. More
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen details, and examples, for each flag, are available in the <a href="/rewrite/flags.html">Rewrite Flags document</a>.</p>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <table class="bordered">
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <tr><th>Flag and syntax</th>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <th>Function</th>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>B</td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>Escape non-alphanumeric characters <em>before</em> applying
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen the transformation. <em><a href="/rewrite/flags.html#flag_b">details ...</a></em></td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>chain|C</td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>Rule is chained to the following rule. If the rule fails,
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen the rule(s) chained to it will be skipped. <em><a href="/rewrite/flags.html#flag_c">details ...</a></em></td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>cookie|CO=<em>NAME</em>:<em>VAL</em></td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>Sets a cookie in the client browser. Full syntax is:
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen CO=<em>NAME</em>:<em>VAL</em>:<em>domain</em>[:<em>lifetime</em>[:<em>path</em>[:<em>secure</em>[:<em>httponly</em>]]]] <em><a href="/rewrite/flags.html#flag_co">details ...</a></em>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>discardpath|DPI</td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>Causes the PATH_INFO portion of the rewritten URI to be
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen discarded. <em><a href="/rewrite/flags.html#flag_dpi">details
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen ...</a></em></td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>env|E=[!]<em>VAR</em>[:<em>VAL</em>]</td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>Causes an environment variable <em>VAR</em> to be set (to the
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen value <em>VAL</em> if provided). The form !<em>VAR</em> causes
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen the environment variable <em>VAR</em> to be unset.<em><a href="/rewrite/flags.html#flag_e">details ...</a></em></td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>forbidden|F</td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>Returns a 403 FORBIDDEN response to the client browser.
1e6708ac9aebbbd0ff63c2b93e6b97d50263a8bbrbowen <em><a href="/rewrite/flags.html#flag_f">details ...</a></em></td>
1e6708ac9aebbbd0ff63c2b93e6b97d50263a8bbrbowen </tr>
1e6708ac9aebbbd0ff63c2b93e6b97d50263a8bbrbowen <tr>
1e6708ac9aebbbd0ff63c2b93e6b97d50263a8bbrbowen <td>gone|G</td>
1e6708ac9aebbbd0ff63c2b93e6b97d50263a8bbrbowen <td>Returns a 410 GONE response to the client browser. <em><a href="/rewrite/flags.html#flag_g">details ...</a></em></td>
1e6708ac9aebbbd0ff63c2b93e6b97d50263a8bbrbowen </tr>
1e6708ac9aebbbd0ff63c2b93e6b97d50263a8bbrbowen <tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>Handler|H=<em>Content-handler</em></td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>Causes the resulting URI to be sent to the specified
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <em>Content-handler</em> for processing. <em><a href="/rewrite/flags.html#flag_h">details ...</a></em></td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <td>last|L</td>
3ad007d5c5f33f127acfb6cacffa7a63d6df1068rbowen <td>Stop the rewriting process immediately and don't apply any
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen more rules. Especially note caveats for per-directory and
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen .htaccess context (see also the END flag). <em><a href="/rewrite/flags.html#flag_end">details ...</a></em></td>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen </tr>
ee9cda8f648f99a0b889cb0831ba5b1efe6b3eb5rbowen <tr>
ff21ab9f1cc3037fe58a2029432834581594b6c4pctony <td>next|N</td>
de68ca33425122cf4a880859013e08e84f8143a5covener <td>Re-run the rewriting process, starting again with the first
de68ca33425122cf4a880859013e08e84f8143a5covener rule, using the result of the ruleset so far as a starting
de68ca33425122cf4a880859013e08e84f8143a5covener point. <em><a href="/rewrite/flags.html#flag_n">details
81785f72c9d133aef57ad6b02f248345d90239aapoirier ...</a></em></td>
4e6d765a1b53690664877065e6b6c741c1b96937covener </tr>
de68ca33425122cf4a880859013e08e84f8143a5covener <tr>
de68ca33425122cf4a880859013e08e84f8143a5covener <td>nocase|NC</td>
de68ca33425122cf4a880859013e08e84f8143a5covener <td>Makes the pattern comparison case-insensitive.
de68ca33425122cf4a880859013e08e84f8143a5covener <em><a href="/rewrite/flags.html#flag_nc">details ...</a></em></td>
de68ca33425122cf4a880859013e08e84f8143a5covener </tr>
de68ca33425122cf4a880859013e08e84f8143a5covener <tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <td>noescape|NE</td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <td>Prevent mod_rewrite from applying hexcode escaping of
06ba4a61654b3763ad65f52283832ebf058fdf1cslive special characters in the result of the rewrite. <em><a href="/rewrite/flags.html#flag_ne">details ...</a></em></td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <tr>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <td>nosubreq|NS</td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <td>Causes a rule to be skipped if the current request is an
97a9a944b5887e91042b019776c41d5dd74557aferikabele internal sub-request. <em><a href="/rewrite/flags.html#flag_ns">details ...</a></em></td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <td>proxy|P</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <td>Force the substitution URL to be internally sent as a proxy
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen request. <em><a href="/rewrite/flags.html#flag_p">details
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen ...</a></em></td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen </tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <td>passthrough|PT</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <td>Forces the resulting URI to be passed back to the URL
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen mapping engine for processing of other URI-to-filename
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen translators, such as <code>Alias</code> or
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <code>Redirect</code>. <em><a href="/rewrite/flags.html#flag_pt">details ...</a></em></td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen </tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <td>qsappend|QSA</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <td>Appends any query string from the original request URL to
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen any query string created in the rewrite target.<em><a href="/rewrite/flags.html#flag_qsa">details ...</a></em></td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen </tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <td>qsdiscard|QSD</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <td>Discard any query string attached to the incoming URI.
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <em><a href="/rewrite/flags.html#flag_qsd">details
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen ...</a></em></td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen </tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <td>redirect|R[=<em>code</em>]</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <td>Forces an external redirect, optionally with the specified
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen HTTP status code. <em><a href="/rewrite/flags.html#flag_r">details ...</a></em>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen </td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen </tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <td>END</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <td>Stop the rewriting process immediately and don't apply any
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen more rules. Also prevents further execution of rewrite rules
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen in per-directory and .htaccess context. (Available in 2.3.9 and later)
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <em><a href="/rewrite/flags.html#flag_l">details ...</a></em></td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen </tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <td>skip|S=<em>num</em></td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <td>Tells the rewriting engine to skip the next <em>num</em>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen rules if the current rule matches. <em><a href="/rewrite/flags.html#flag_s">details ...</a></em></td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen </tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <td>type|T=<em>MIME-type</em></td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <td>Force the <a class="glossarylink" href="/glossary.html#mime-type" title="see glossary">MIME-type</a> of the target file
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen to be the specified type. <em><a href="/rewrite/flags.html#flag_t">details ...</a></em></td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen </tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen </table>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<div class="note"><h3>Home directory expansion</h3>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<p> When the substitution string begins with a string
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowenresembling "/~user" (via explicit text or backreferences), mod_rewrite performs
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowenhome directory expansion independent of the presence or configuration
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowenof <code class="module"><a href="/mod/mod_userdir.html">mod_userdir</a></code>.</p>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<p> This expansion does not occur when the <em>PT</em>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowenflag is used on the <code class="directive"><a href="#rewriterule">RewriteRule</a></code>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowendirective.</p>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</div>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <p>Here are all possible substitution combinations and their
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen meanings:</p>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <p><strong>Inside per-server configuration
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen (<code>httpd.conf</code>)<br />
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen for request ``<code>GET
06ba4a61654b3763ad65f52283832ebf058fdf1cslive /somepath/pathinfo</code>'':</strong><br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </p>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<table class="bordered">
97a9a944b5887e91042b019776c41d5dd74557aferikabele<tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<th>Given Rule</th>
81785f72c9d133aef57ad6b02f248345d90239aapoirier<th>Resulting Substitution</th>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^/somepath(.*) otherpath$1</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>invalid, not supported</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^/somepath(.*) otherpath$1 [R]</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>invalid, not supported</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^/somepath(.*) otherpath$1 [P]</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>invalid, not supported</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^/somepath(.*) /otherpath$1</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>/otherpath/pathinfo</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^/somepath(.*) /otherpath$1 [R]</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>http://thishost/otherpath/pathinfo via external redirection</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^/somepath(.*) /otherpath$1 [P]</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>doesn't make sense, not supported</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^/somepath(.*) http://thishost/otherpath$1</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>/otherpath/pathinfo</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^/somepath(.*) http://thishost/otherpath$1 [R]</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>http://thishost/otherpath/pathinfo via external redirection</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^/somepath(.*) http://thishost/otherpath$1 [P]</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>doesn't make sense, not supported</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^/somepath(.*) http://otherhost/otherpath$1</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>http://otherhost/otherpath/pathinfo via external redirection</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^/somepath(.*) http://otherhost/otherpath$1 [R]</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>http://otherhost/otherpath/pathinfo via external redirection (the [R] flag is redundant)</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>^/somepath(.*) http://otherhost/otherpath$1 [P]</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen<td>http://otherhost/otherpath/pathinfo via internal proxy</td>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</tr>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen</table>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <p><strong>Inside per-directory configuration for
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <code>/somepath</code><br />
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen (<code>/physical/path/to/somepath/.htaccess</code>, with
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen <code>RewriteBase /somepath</code>)<br />
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen for request ``<code>GET
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen /somepath/localpath/pathinfo</code>'':</strong><br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </p>
34212fdb21f03f4e180a3226f83e39af0371d7dbrbowen
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<table class="bordered">
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<th>Given Rule</th>
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd<th>Resulting Substitution</th>
7dc5a2d4a0c77f5bf5a95de92d68e43de7d8117anilgun</tr>
7dc5a2d4a0c77f5bf5a95de92d68e43de7d8117anilgun
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd<tr>
9c1260efa52c82c2a58e5b5f20cd6902563d95f5rbowen<td>^localpath(.*) otherpath$1</td>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<td>/somepath/otherpath/pathinfo</td>
0c0b2cdbccd4ddc8f07574c36444bf9a795a3e1cjim</tr>
<tr>
<td>^localpath(.*) otherpath$1 [R]</td>
<td>http://thishost/somepath/otherpath/pathinfo via external
redirection</td>
</tr>
<tr>
<td>^localpath(.*) otherpath$1 [P]</td>
<td>doesn't make sense, not supported</td>
</tr>
<tr>
<td>^localpath(.*) /otherpath$1</td>
<td>/otherpath/pathinfo</td>
</tr>
<tr>
<td>^localpath(.*) /otherpath$1 [R]</td>
<td>http://thishost/otherpath/pathinfo via external redirection</td>
</tr>
<tr>
<td>^localpath(.*) /otherpath$1 [P]</td>
<td>doesn't make sense, not supported</td>
</tr>
<tr>
<td>^localpath(.*) http://thishost/otherpath$1</td>
<td>/otherpath/pathinfo</td>
</tr>
<tr>
<td>^localpath(.*) http://thishost/otherpath$1 [R]</td>
<td>http://thishost/otherpath/pathinfo via external redirection</td>
</tr>
<tr>
<td>^localpath(.*) http://thishost/otherpath$1 [P]</td>
<td>doesn't make sense, not supported</td>
</tr>
<tr>
<td>^localpath(.*) http://otherhost/otherpath$1</td>
<td>http://otherhost/otherpath/pathinfo via external redirection</td>
</tr>
<tr>
<td>^localpath(.*) http://otherhost/otherpath$1 [R]</td>
<td>http://otherhost/otherpath/pathinfo via external redirection (the [R] flag is redundant)</td>
</tr>
<tr>
<td>^localpath(.*) http://otherhost/otherpath$1 [P]</td>
<td>http://otherhost/otherpath/pathinfo via internal proxy</td>
</tr>
</table>
</div>
</div>
<div class="bottomlang">
<p><span>Available Languages: </span><a href="/en/mod/mod_rewrite.html" title="English">&nbsp;en&nbsp;</a> |
<a href="/fr/mod/mod_rewrite.html" hreflang="fr" rel="alternate" title="Fran�ais">&nbsp;fr&nbsp;</a></p>
</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>
<script type="text/javascript"><!--//--><![CDATA[//><!--
var comments_shortname = 'httpd';
var comments_identifier = 'http://httpd.apache.org/docs/trunk/mod/mod_rewrite.html';
(function(w, d) {
if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
d.write('<div id="comments_thread"><\/div>');
var s = d.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
(d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
}
else {
d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
}
})(window, document);
//--><!]]></script></div><div id="footer">
<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>
<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[//><!--
if (typeof(prettyPrint) !== 'undefined') {
prettyPrint();
}
//--><!]]></script>
</body></html>