mod_rewrite.html.en revision fa0f379e3845907d7c1087d885169e302239bdbb
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" />
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<link href="/images/favicon.ico" rel="shortcut icon" /></head>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<body>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div id="page-header">
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="/faq/">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p>
52fff662005b1866a3ff09bb6c902800c5cc6dedjerenkrantz<p class="apache">Apache HTTP Server Version 2.3</p>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<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">
4b5981e276e93df97c34e4da05ca5cf8bbd937dand<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.3</a> &gt; <a href="./">Modules</a></div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div id="page-content">
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div id="preamble"><h1>Apache Module mod_rewrite</h1>
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd<div class="toplang">
7dc5a2d4a0c77f5bf5a95de92d68e43de7d8117anilgun<p><span>Available Languages: </span><a href="/en/mod/mod_rewrite.html" title="English">&nbsp;en&nbsp;</a> |
7dc5a2d4a0c77f5bf5a95de92d68e43de7d8117anilgun<a href="/fr/mod/mod_rewrite.html" hreflang="fr" rel="alternate" title="Fran�ais">&nbsp;fr&nbsp;</a></p>
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd</div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Provides a rule-based rewriting engine to rewrite requested
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4ndURLs on the fly</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="module-dict.html#Status">Status:</a></th><td>Extension</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="module-dict.html#ModuleIdentifier">Module�Identifier:</a></th><td>rewrite_module</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="module-dict.html#SourceFile">Source�File:</a></th><td>mod_rewrite.c</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="module-dict.html#Compatibility">Compatibility:</a></th><td>Available in Apache 1.3 and later</td></tr></table>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<h3>Summary</h3>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>The <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> module uses a rule-based rewriting
06ba4a61654b3763ad65f52283832ebf058fdf1cslive engine, based on a regular-expression parser, to rewrite requested URLs on
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the fly. By default, <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> maps a URL to a filesystem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem path. However, it can also be used to redirect one URL to another URL, or
06ba4a61654b3763ad65f52283832ebf058fdf1cslive to invoke an internal proxy fetch.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p><code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> provides a flexible and powerful way to
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem manipulate URLs using an unlimited number of rules. Each rule can have an
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem unlimited number of attached rule conditions, to allow you to rewrite URL
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem based on server variables, environment variables, HTTP headers, or time
06ba4a61654b3763ad65f52283832ebf058fdf1cslive stamps.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p><code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> operates on the full URL path, including the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive path-info section. A rewrite rule can be invoked in
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>httpd.conf</code> or in <code>.htaccess</code>. The path generated
06ba4a61654b3763ad65f52283832ebf058fdf1cslive by a rewrite rule can include a query string, or can lead to internal
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem sub-processing, external request redirection, or internal proxy
06ba4a61654b3763ad65f52283832ebf058fdf1cslive throughput.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>Further details, discussion, and examples, are provided in the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <a href="/rewrite/">detailed mod_rewrite documentation</a>.</p>
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen</div>
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen<div id="quickview"><h3 class="directives">Directives</h3>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<ul id="toc">
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<li><img alt="" src="/images/down.gif" /> <a href="#rewritebase">RewriteBase</a></li>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<li><img alt="" src="/images/down.gif" /> <a href="#rewritecond">RewriteCond</a></li>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<li><img alt="" src="/images/down.gif" /> <a href="#rewriteengine">RewriteEngine</a></li>
117c1f888a14e73cdd821dc6c23eb0411144a41cnd<li><img alt="" src="/images/down.gif" /> <a href="#rewritelog">RewriteLog</a></li>
117c1f888a14e73cdd821dc6c23eb0411144a41cnd<li><img alt="" src="/images/down.gif" /> <a href="#rewriteloglevel">RewriteLogLevel</a></li>
117c1f888a14e73cdd821dc6c23eb0411144a41cnd<li><img alt="" src="/images/down.gif" /> <a href="#rewritemap">RewriteMap</a></li>
117c1f888a14e73cdd821dc6c23eb0411144a41cnd<li><img alt="" src="/images/down.gif" /> <a href="#rewriteoptions">RewriteOptions</a></li>
117c1f888a14e73cdd821dc6c23eb0411144a41cnd<li><img alt="" src="/images/down.gif" /> <a href="#rewriterule">RewriteRule</a></li>
117c1f888a14e73cdd821dc6c23eb0411144a41cnd</ul>
117c1f888a14e73cdd821dc6c23eb0411144a41cnd</div>
117c1f888a14e73cdd821dc6c23eb0411144a41cnd
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="RewriteBase" id="RewriteBase">RewriteBase</a> <a name="rewritebase" id="rewritebase">Directive</a></h2>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<table class="directive">
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen<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>
4c36c711036219c80d5517d35be68a4769c15291slive<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>
ff21ab9f1cc3037fe58a2029432834581594b6c4pctony<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
ff21ab9f1cc3037fe58a2029432834581594b6c4pctony<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
ff21ab9f1cc3037fe58a2029432834581594b6c4pctony<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</table>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <p>The <code class="directive">RewriteBase</code> directive explicitly
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd sets the base URL-path (not filesystem directory path!) for per-directory rewrites.
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen When you use a <code class="directive"><a href="#rewriterule">RewriteRule</a></code>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive in a <code>.htaccess</code> file, <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> strips off
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the local directory prefix before processing, then rewrites the rest of
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the URL. When the rewrite is completed, <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive automatically adds the local directory prefix back on to the path.</p>
b95ae799514ad86a15610ad75808d7065e9847c9kess
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>This directive is <em>required</em> for per-directory rewrites whose context
06ba4a61654b3763ad65f52283832ebf058fdf1cslive is a directory made available via the <code class="directive"><a href="/mod/mod_alias.html#alias">Alias</a></code>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive directive.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen <p>If your URL path does not exist verbatim on the filesystem,
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen or isn't directly under your <code class="directive"><a href="/mod/core.html#documentroot">DocumentRoot</a></code>,
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd you must use <code class="directive">RewriteBase</code> in every
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>.htaccess</code> file where you want to use <code class="directive"><a href="#rewriterule">RewriteRule</a></code> directives.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>The example below demonstrates how to map
06ba4a61654b3763ad65f52283832ebf058fdf1cslive http://example.com/myapp/index.html to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive /home/www/example/newsite.html, in a <code>.htaccess</code> file. This
06ba4a61654b3763ad65f52283832ebf058fdf1cslive assumes that the content available at
06ba4a61654b3763ad65f52283832ebf058fdf1cslive http://example.com/ is on disk at /home/www/example/</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<div class="example"><pre>
06ba4a61654b3763ad65f52283832ebf058fdf1csliveRewriteEngine On
06ba4a61654b3763ad65f52283832ebf058fdf1cslive# The URL-path used to get to this context, not the filesystem path
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluemRewriteBase /myapp/
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluemRewriteRule ^index\.html$ newsite.html
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</pre></div>
a4d04b8c74044c58bd4182028a1408d936c95951covener
a4d04b8c74044c58bd4182028a1408d936c95951covener
a4d04b8c74044c58bd4182028a1408d936c95951covener</div>
a4d04b8c74044c58bd4182028a1408d936c95951covener<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
a4d04b8c74044c58bd4182028a1408d936c95951covener<div class="directive-section"><h2><a name="RewriteCond" id="RewriteCond">RewriteCond</a> <a name="rewritecond" id="rewritecond">Directive</a></h2>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<table class="directive">
97a9a944b5887e91042b019776c41d5dd74557aferikabele<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Defines a condition under which rewriting will take place
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code> RewriteCond
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>TestString</em> <em>CondPattern</em></code></td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
97a9a944b5887e91042b019776c41d5dd74557aferikabele<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
4c36c711036219c80d5517d35be68a4769c15291slive<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
4c36c711036219c80d5517d35be68a4769c15291slive</table>
4c36c711036219c80d5517d35be68a4769c15291slive <p>The <code class="directive">RewriteCond</code> directive defines a
4c36c711036219c80d5517d35be68a4769c15291slive rule condition. One or more <code class="directive">RewriteCond</code>
4c36c711036219c80d5517d35be68a4769c15291slive can precede a <code class="directive"><a href="#rewriterule">RewriteRule</a></code>
4c36c711036219c80d5517d35be68a4769c15291slive directive. The following rule is then only used if both
4c36c711036219c80d5517d35be68a4769c15291slive the current state of the URI matches its pattern, <strong>and</strong> if these conditions are met.</p>
4c36c711036219c80d5517d35be68a4769c15291slive
4c36c711036219c80d5517d35be68a4769c15291slive <p><em>TestString</em> is a string which can contain the
4c36c711036219c80d5517d35be68a4769c15291slive following expanded constructs in addition to plain text:</p>
4c36c711036219c80d5517d35be68a4769c15291slive
f736cd11585a35572d5f42accf026eb667848434slive <ul>
4c36c711036219c80d5517d35be68a4769c15291slive <li>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <strong>RewriteRule backreferences</strong>: These are
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd backreferences of the form <strong><code>$N</code></strong>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd (0 &lt;= N &lt;= 9), which provide access to the grouped
06ba4a61654b3763ad65f52283832ebf058fdf1cslive parts (in parentheses) of the pattern, from the
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen <code>RewriteRule</code> which is subject to the current
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen set of <code>RewriteCond</code> conditions.
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen </li>
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen <li>
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen <strong>RewriteCond backreferences</strong>: These are
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd backreferences of the form <strong><code>%N</code></strong>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd (1 &lt;= N &lt;= 9), which provide access to the grouped
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd parts (again, in parentheses) of the pattern, from the last matched
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <code>RewriteCond</code> in the current set
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd of conditions.
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd </li>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <li>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <strong>RewriteMap expansions</strong>: These are
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd expansions of the form <strong><code>${mapname:key|default}</code></strong>.
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd See <a href="#mapfunc">the documentation for
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd RewriteMap</a> for more details.
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd </li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong>Server-Variables</strong>: These are variables of
97a9a944b5887e91042b019776c41d5dd74557aferikabele the form
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong><code>%{</code> <em>NAME_OF_VARIABLE</em>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>}</code></strong>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem where <em>NAME_OF_VARIABLE</em> can be a string taken
81785f72c9d133aef57ad6b02f248345d90239aapoirier from the following list:
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <table>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <th>HTTP headers:</th> <th>connection &amp; request:</th> <th />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <td>
81785f72c9d133aef57ad6b02f248345d90239aapoirier HTTP_USER_AGENT<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive HTTP_REFERER<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive HTTP_COOKIE<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive HTTP_FORWARDED<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele HTTP_HOST<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem HTTP_PROXY_CONNECTION<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive HTTP_ACCEPT<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem </td>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive REMOTE_ADDR<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive REMOTE_HOST<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele REMOTE_PORT<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive REMOTE_USER<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive REMOTE_IDENT<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive REQUEST_METHOD<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive SCRIPT_FILENAME<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive PATH_INFO<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive QUERY_STRING<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive AUTH_TYPE<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <td />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <th>server internals:</th> <th>date and time:</th> <th>specials:</th>
97a9a944b5887e91042b019776c41d5dd74557aferikabele </tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive DOCUMENT_ROOT<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive SERVER_ADMIN<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele SERVER_NAME<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive SERVER_ADDR<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive SERVER_PORT<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive SERVER_PROTOCOL<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive SERVER_SOFTWARE<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive TIME_YEAR<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive TIME_MON<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive TIME_DAY<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive TIME_HOUR<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive TIME_MIN<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive TIME_SEC<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive TIME_WDAY<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive TIME<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem </td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <td>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem API_VERSION<br />
f2f7bfe0e3e57940b386bdbcb266eea78a86aa24rbowen THE_REQUEST<br />
f2f7bfe0e3e57940b386bdbcb266eea78a86aa24rbowen REQUEST_URI<br />
f2f7bfe0e3e57940b386bdbcb266eea78a86aa24rbowen REQUEST_FILENAME<br />
81785f72c9d133aef57ad6b02f248345d90239aapoirier IS_SUBREQ<br />
81785f72c9d133aef57ad6b02f248345d90239aapoirier HTTPS<br />
81785f72c9d133aef57ad6b02f248345d90239aapoirier </td>
81785f72c9d133aef57ad6b02f248345d90239aapoirier </tr>
97a9a944b5887e91042b019776c41d5dd74557aferikabele </table>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <p>These variables all
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd correspond to the similarly named HTTP
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd MIME-headers, C variables of the Apache server or
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <code>struct tm</code> fields of the Unix system.
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd Most are documented elsewhere in the Manual or in
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd the CGI specification. Those that are special to
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd mod_rewrite include those below.</p>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <div class="note">
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <dl>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <dt><code>IS_SUBREQ</code></dt>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <dd>Will contain the text "true" if the request
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd currently being processed is a sub-request,
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd "false" otherwise. Sub-requests may be generated
06ba4a61654b3763ad65f52283832ebf058fdf1cslive by modules that need to resolve additional files
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem or URIs in order to complete their tasks.</dd>
81785f72c9d133aef57ad6b02f248345d90239aapoirier
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <dt><code>API_VERSION</code></dt>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dd>This is the version of the Apache module API
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem (the internal interface between server and
06ba4a61654b3763ad65f52283832ebf058fdf1cslive module) in the current httpd build, as defined in
06ba4a61654b3763ad65f52283832ebf058fdf1cslive include/ap_mmn.h. The module API version
06ba4a61654b3763ad65f52283832ebf058fdf1cslive corresponds to the version of Apache in use (in
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the release version of Apache 1.3.14, for
06ba4a61654b3763ad65f52283832ebf058fdf1cslive instance, it is 19990320:10), but is mainly of
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem interest to module authors.</dd>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <dt><code>THE_REQUEST</code></dt>
81785f72c9d133aef57ad6b02f248345d90239aapoirier
a4d04b8c74044c58bd4182028a1408d936c95951covener <dd>The full HTTP request line sent by the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive browser to the server (e.g., "<code>GET
06ba4a61654b3763ad65f52283832ebf058fdf1cslive /index.html HTTP/1.1</code>"). This does not
06ba4a61654b3763ad65f52283832ebf058fdf1cslive include any additional headers sent by the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem browser.</dd>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <dt><code>REQUEST_URI</code></dt>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dd>The resource requested in the HTTP request
06ba4a61654b3763ad65f52283832ebf058fdf1cslive line. (In the example above, this would be
06ba4a61654b3763ad65f52283832ebf058fdf1cslive "/index.html".)</dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <dt><code>REQUEST_FILENAME</code></dt>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dd>The full local filesystem path to the file or
06ba4a61654b3763ad65f52283832ebf058fdf1cslive script matching the request.</dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dt><code>HTTPS</code></dt>
81785f72c9d133aef57ad6b02f248345d90239aapoirier
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dd>Will contain the text "on" if the connection is
06ba4a61654b3763ad65f52283832ebf058fdf1cslive using SSL/TLS, or "off" otherwise. (This variable
06ba4a61654b3763ad65f52283832ebf058fdf1cslive can be safely used regardless of whether or not
81785f72c9d133aef57ad6b02f248345d90239aapoirier <code class="module"><a href="/mod/mod_ssl.html">mod_ssl</a></code> is loaded).</dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele </dl>
c6a2d6fa44f8698851dec5051ee3782c2913605fnd</div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </li>
97a9a944b5887e91042b019776c41d5dd74557aferikabele </ul>
5ae30adbe59946de742ab0cd6be3b7457471a698takashi
97a9a944b5887e91042b019776c41d5dd74557aferikabele <p>Other things you should be aware of:</p>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
5ae30adbe59946de742ab0cd6be3b7457471a698takashi <ol>
5ae30adbe59946de742ab0cd6be3b7457471a698takashi <li>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <p>The variables SCRIPT_FILENAME and REQUEST_FILENAME
97a9a944b5887e91042b019776c41d5dd74557aferikabele contain the same value - the value of the
97a9a944b5887e91042b019776c41d5dd74557aferikabele <code>filename</code> field of the internal
97a9a944b5887e91042b019776c41d5dd74557aferikabele <code>request_rec</code> structure of the Apache server.
97a9a944b5887e91042b019776c41d5dd74557aferikabele The first name is the commonly known CGI variable name
97a9a944b5887e91042b019776c41d5dd74557aferikabele while the second is the appropriate counterpart of
06ba4a61654b3763ad65f52283832ebf058fdf1cslive REQUEST_URI (which contains the value of the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>uri</code> field of <code>request_rec</code>).</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>If a substitution occurred and the rewriting continues,
97a9a944b5887e91042b019776c41d5dd74557aferikabele the value of both variables will be updated accordingly.</p>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <p>If used in per-server context (<em>i.e.</em>, before the
74a6de79356cd15d2e47065087785e36dd65aa41nd request is mapped to the filesystem) SCRIPT_FILENAME and
97a9a944b5887e91042b019776c41d5dd74557aferikabele REQUEST_FILENAME cannot contain the full local filesystem
97a9a944b5887e91042b019776c41d5dd74557aferikabele path since the path is unknown at this stage of processing.
97a9a944b5887e91042b019776c41d5dd74557aferikabele Both variables will initially contain the value of REQUEST_URI
97a9a944b5887e91042b019776c41d5dd74557aferikabele in that case. In order to obtain the full local filesystem
97a9a944b5887e91042b019776c41d5dd74557aferikabele path of the request in per-server context, use an URL-based
97a9a944b5887e91042b019776c41d5dd74557aferikabele look-ahead <code>%{LA-U:REQUEST_FILENAME}</code> to determine
97a9a944b5887e91042b019776c41d5dd74557aferikabele the final value of REQUEST_FILENAME.</p></li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
5ae30adbe59946de742ab0cd6be3b7457471a698takashi <li>
5ae30adbe59946de742ab0cd6be3b7457471a698takashi <code>%{ENV:variable}</code>, where <em>variable</em> can be
06ba4a61654b3763ad65f52283832ebf058fdf1cslive any environment variable, is also available.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive This is looked-up via internal
06ba4a61654b3763ad65f52283832ebf058fdf1cslive Apache structures and (if not found there) via
53d2fd50ff45e7c568f0588c742a5ef9edf8e275rbowen <code>getenv()</code> from the Apache server process.</li>
5ae30adbe59946de742ab0cd6be3b7457471a698takashi
97a9a944b5887e91042b019776c41d5dd74557aferikabele <li>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <code>%{SSL:variable}</code>, where <em>variable</em> is the
5ae30adbe59946de742ab0cd6be3b7457471a698takashi name of an <a href="mod_ssl.html#envvars">SSL environment
5ae30adbe59946de742ab0cd6be3b7457471a698takashi variable</a>, can be used whether or not
97a9a944b5887e91042b019776c41d5dd74557aferikabele <code class="module"><a href="/mod/mod_ssl.html">mod_ssl</a></code> is loaded, but will always expand to
97a9a944b5887e91042b019776c41d5dd74557aferikabele the empty string if it is not. Example:
97a9a944b5887e91042b019776c41d5dd74557aferikabele <code>%{SSL:SSL_CIPHER_USEKEYSIZE}</code> may expand to
97a9a944b5887e91042b019776c41d5dd74557aferikabele <code>128</code>.</li>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
97a9a944b5887e91042b019776c41d5dd74557aferikabele <li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>%{HTTP:header}</code>, where <em>header</em> can be
06ba4a61654b3763ad65f52283832ebf058fdf1cslive any HTTP MIME-header name, can always be used to obtain the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive value of a header sent in the HTTP request.
97a9a944b5887e91042b019776c41d5dd74557aferikabele Example: <code>%{HTTP:Proxy-Connection}</code> is
97a9a944b5887e91042b019776c41d5dd74557aferikabele the value of the HTTP header
97a9a944b5887e91042b019776c41d5dd74557aferikabele ``<code>Proxy-Connection:</code>''.
97a9a944b5887e91042b019776c41d5dd74557aferikabele <p>If a HTTP header is used in a condition this header is added to
97a9a944b5887e91042b019776c41d5dd74557aferikabele the Vary header of the response in case the condition evaluates to
97a9a944b5887e91042b019776c41d5dd74557aferikabele to true for the request. It is <strong>not</strong> added if the
97a9a944b5887e91042b019776c41d5dd74557aferikabele condition evaluates to false for the request. Adding the HTTP header
97a9a944b5887e91042b019776c41d5dd74557aferikabele to the Vary header of the response is needed for proper caching.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>It has to be kept in mind that conditions follow a short circuit
06ba4a61654b3763ad65f52283832ebf058fdf1cslive logic in the case of the '<strong><code>ornext|OR</code></strong>' flag
06ba4a61654b3763ad65f52283832ebf058fdf1cslive so that certain conditions might not be evaluated at all.</p></li>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
97a9a944b5887e91042b019776c41d5dd74557aferikabele <li>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <code>%{LA-U:variable}</code> can be used for look-aheads which perform
97a9a944b5887e91042b019776c41d5dd74557aferikabele an internal (URL-based) sub-request to determine the final
97a9a944b5887e91042b019776c41d5dd74557aferikabele value of <em>variable</em>. This can be used to access
fb82af0f0cd7b58eef19c54b086131b7e1e1e749madhum variable for rewriting which is not available at the current
06ba4a61654b3763ad65f52283832ebf058fdf1cslive stage, but will be set in a later phase.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>For instance, to rewrite according to the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>REMOTE_USER</code> variable from within the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive per-server context (<code>httpd.conf</code> file) you must
06ba4a61654b3763ad65f52283832ebf058fdf1cslive use <code>%{LA-U:REMOTE_USER}</code> - this
06ba4a61654b3763ad65f52283832ebf058fdf1cslive variable is set by the authorization phases, which come
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>after</em> the URL translation phase (during which mod_rewrite
06ba4a61654b3763ad65f52283832ebf058fdf1cslive operates).</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>On the other hand, because mod_rewrite implements
06ba4a61654b3763ad65f52283832ebf058fdf1cslive its per-directory context (<code>.htaccess</code> file) via
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem the Fixup phase of the API and because the authorization
5ae30adbe59946de742ab0cd6be3b7457471a698takashi phases come <em>before</em> this phase, you just can use
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>%{REMOTE_USER}</code> in that context.</p></li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>%{LA-F:variable}</code> can be used to perform an internal
06ba4a61654b3763ad65f52283832ebf058fdf1cslive (filename-based) sub-request, to determine the final value
06ba4a61654b3763ad65f52283832ebf058fdf1cslive of <em>variable</em>. Most of the time, this is the same as
06ba4a61654b3763ad65f52283832ebf058fdf1cslive LA-U above.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </ol>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p><em>CondPattern</em> is the condition pattern,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive a regular expression which is applied to the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive current instance of the <em>TestString</em>.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>TestString</em> is first evaluated, before being matched against
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>CondPattern</em>.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p><strong>Remember:</strong> <em>CondPattern</em> is a
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>perl compatible regular expression</em> with some
06ba4a61654b3763ad65f52283832ebf058fdf1cslive additions:</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <ol>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>You can prefix the pattern string with a
06ba4a61654b3763ad65f52283832ebf058fdf1cslive '<code>!</code>' character (exclamation mark) to specify a
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong>non</strong>-matching pattern.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive There are some special variants of <em>CondPatterns</em>.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive Instead of real regular expression strings you can also
06ba4a61654b3763ad65f52283832ebf058fdf1cslive use one of the following:
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <ul>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>'<strong>&lt;CondPattern</strong>' (lexicographically
06ba4a61654b3763ad65f52283832ebf058fdf1cslive precedes)<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive Treats the <em>CondPattern</em> as a plain string and
06ba4a61654b3763ad65f52283832ebf058fdf1cslive compares it lexicographically to <em>TestString</em>. True if
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>TestString</em> lexicographically precedes
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>CondPattern</em>.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>'<strong>&gt;CondPattern</strong>' (lexicographically
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd follows)<br />
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd Treats the <em>CondPattern</em> as a plain string and
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd compares it lexicographically to <em>TestString</em>. True if
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd <em>TestString</em> lexicographically follows
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd <em>CondPattern</em>.</li>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd <li>'<strong>=CondPattern</strong>' (lexicographically
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd equal)<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive Treats the <em>CondPattern</em> as a plain string and
97a9a944b5887e91042b019776c41d5dd74557aferikabele compares it lexicographically to <em>TestString</em>. True if
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>TestString</em> is lexicographically equal to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>CondPattern</em> (the two strings are exactly
06ba4a61654b3763ad65f52283832ebf058fdf1cslive equal, character for character). If <em>CondPattern</em>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem is <code>""</code> (two quotation marks) this
06ba4a61654b3763ad65f52283832ebf058fdf1cslive compares <em>TestString</em> to the empty string.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
a4d04b8c74044c58bd4182028a1408d936c95951covener <li>'<strong>-d</strong>' (is
a4d04b8c74044c58bd4182028a1408d936c95951covener <strong>d</strong>irectory)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Treats the <em>TestString</em> as a pathname and tests
06ba4a61654b3763ad65f52283832ebf058fdf1cslive whether or not it exists, and is a directory.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>'<strong>-f</strong>' (is regular
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <strong>f</strong>ile)<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive Treats the <em>TestString</em> as a pathname and tests
a4d04b8c74044c58bd4182028a1408d936c95951covener whether or not it exists, and is a regular file.</li>
a4d04b8c74044c58bd4182028a1408d936c95951covener
a4d04b8c74044c58bd4182028a1408d936c95951covener <li>'<strong>-s</strong>' (is regular file, with
a4d04b8c74044c58bd4182028a1408d936c95951covener <strong>s</strong>ize)<br />
a4d04b8c74044c58bd4182028a1408d936c95951covener Treats the <em>TestString</em> as a pathname and tests
a4d04b8c74044c58bd4182028a1408d936c95951covener whether or not it exists, and is a regular file with size greater
a4d04b8c74044c58bd4182028a1408d936c95951covener than zero.</li>
a4d04b8c74044c58bd4182028a1408d936c95951covener
a4d04b8c74044c58bd4182028a1408d936c95951covener <li>'<strong>-l</strong>' (is symbolic
a4d04b8c74044c58bd4182028a1408d936c95951covener <strong>l</strong>ink)<br />
a4d04b8c74044c58bd4182028a1408d936c95951covener Treats the <em>TestString</em> as a pathname and tests
a4d04b8c74044c58bd4182028a1408d936c95951covener whether or not it exists, and is a symbolic link.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>'<strong>-x</strong>' (has e<strong>x</strong>ecutable
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem permissions)<br />
81785f72c9d133aef57ad6b02f248345d90239aapoirier Treats the <em>TestString</em> as a pathname and tests
5ae30adbe59946de742ab0cd6be3b7457471a698takashi whether or not it exists, and has executable permissions.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive These permissions are determined according to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the underlying OS.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>'<strong>-F</strong>' (is existing file, via
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem subrequest)<br />
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd Checks whether or not <em>TestString</em> is a valid file,
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem accessible via all the server's currently-configured
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd access controls for that path. This uses an internal
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd subrequest to do the check, so use it with care -
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd it can impact your server's performance!</li>
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd
fb82af0f0cd7b58eef19c54b086131b7e1e1e749madhum <li>'<strong>-U</strong>' (is existing URL, via
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem subrequest)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Checks whether or not <em>TestString</em> is a valid URL,
5ae30adbe59946de742ab0cd6be3b7457471a698takashi accessible via all the server's currently-configured
5ae30adbe59946de742ab0cd6be3b7457471a698takashi access controls for that path. This uses an internal
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem subrequest to do the check, so use it with care -
06ba4a61654b3763ad65f52283832ebf058fdf1cslive it can impact your server's performance!</li>
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl </ul>
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl<div class="note"><h3>Note:</h3>
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl All of these tests can
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl also be prefixed by an exclamation mark ('!') to
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl negate their meaning.
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl</div>
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl </li>
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>You can also set special flags for
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <em>CondPattern</em> by appending
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <strong><code>[</code><em>flags</em><code>]</code></strong>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive as the third argument to the <code>RewriteCond</code>
5ae30adbe59946de742ab0cd6be3b7457471a698takashi directive, where <em>flags</em> is a comma-separated list of any of the
81785f72c9d133aef57ad6b02f248345d90239aapoirier following flags:
5ae30adbe59946de742ab0cd6be3b7457471a698takashi
5ae30adbe59946de742ab0cd6be3b7457471a698takashi <ul>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>'<strong><code>nocase|NC</code></strong>'
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem (<strong>n</strong>o <strong>c</strong>ase)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem This makes the test case-insensitive - differences
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem between 'A-Z' and 'a-z' are ignored, both in the
5ae30adbe59946de742ab0cd6be3b7457471a698takashi expanded <em>TestString</em> and the <em>CondPattern</em>.
5ae30adbe59946de742ab0cd6be3b7457471a698takashi This flag is effective only for comparisons between
5ae30adbe59946de742ab0cd6be3b7457471a698takashi <em>TestString</em> and <em>CondPattern</em>. It has no
06ba4a61654b3763ad65f52283832ebf058fdf1cslive effect on filesystem and subrequest checks.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
5ae30adbe59946de742ab0cd6be3b7457471a698takashi '<strong><code>ornext|OR</code></strong>'
06ba4a61654b3763ad65f52283832ebf058fdf1cslive (<strong>or</strong> next condition)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Use this to combine rule conditions with a local OR
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem instead of the implicit AND. Typical example:
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<div class="example"><pre>
06ba4a61654b3763ad65f52283832ebf058fdf1csliveRewriteCond %{REMOTE_HOST} ^host1.* [OR]
06ba4a61654b3763ad65f52283832ebf058fdf1csliveRewriteCond %{REMOTE_HOST} ^host2.* [OR]
06ba4a61654b3763ad65f52283832ebf058fdf1csliveRewriteCond %{REMOTE_HOST} ^host3.*
06ba4a61654b3763ad65f52283832ebf058fdf1csliveRewriteRule ...some special stuff for any of these hosts...
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem</pre></div>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Without this flag you would have to write the condition/rule
06ba4a61654b3763ad65f52283832ebf058fdf1cslive pair three times.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
630c456b6461158be6cc5c5483735e27b13b4ad5nd <li>'<strong><code>novary|NV</code></strong>'
06ba4a61654b3763ad65f52283832ebf058fdf1cslive (<strong>n</strong>o <strong>v</strong>ary)<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive If a HTTP header is used in the condition, this flag prevents
06ba4a61654b3763ad65f52283832ebf058fdf1cslive this header from being added to the Vary header of the response. <br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive Using this flag might break proper caching of the response if
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the representation of this response varies on the value of this header.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive So this flag should be only used if the meaning of the Vary header
06ba4a61654b3763ad65f52283832ebf058fdf1cslive is well understood.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </ul>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </li>
81785f72c9d133aef57ad6b02f248345d90239aapoirier </ol>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p><strong>Example:</strong></p>
81785f72c9d133aef57ad6b02f248345d90239aapoirier
5ae30adbe59946de742ab0cd6be3b7457471a698takashi <p>To rewrite the Homepage of a site according to the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem ``<code>User-Agent:</code>'' header of the request, you can
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem use the following: </p>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<div class="example"><pre>
06ba4a61654b3763ad65f52283832ebf058fdf1csliveRewriteCond %{HTTP_USER_AGENT} ^Mozilla.*
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluemRewriteRule ^/$ /homepage.max.html [L]
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluemRewriteCond %{HTTP_USER_AGENT} ^Lynx.*
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluemRewriteRule ^/$ /homepage.min.html [L]
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
06ba4a61654b3763ad65f52283832ebf058fdf1csliveRewriteRule ^/$ /homepage.std.html [L]
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</pre></div>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
97a9a944b5887e91042b019776c41d5dd74557aferikabele <p>Explanation: If you use a browser which identifies itself
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem as 'Mozilla' (including Netscape Navigator, Mozilla etc), then you
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem get the max homepage (which could include frames, or other special
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem features).
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem If you use the Lynx browser (which is terminal-based), then
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem you get the min homepage (which could be a version designed for
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem easy, text-only browsing).
06ba4a61654b3763ad65f52283832ebf058fdf1cslive If neither of these conditions apply (you use any other browser,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive or your browser identifies itself as something non-standard), you get
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the std (standard) homepage.</p>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem</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>
97a9a944b5887e91042b019776c41d5dd74557aferikabele<table class="directive">
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Enables or disables runtime rewriting engine</td></tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<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>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
97a9a944b5887e91042b019776c41d5dd74557aferikabele<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</table>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>The <code class="directive">RewriteEngine</code> directive enables or
97a9a944b5887e91042b019776c41d5dd74557aferikabele disables the runtime rewriting engine. If it is set to
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>off</code> this module does no runtime processing at
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem all. It does not even update the <code>SCRIPT_URx</code>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive environment variables.</p>
4e3cdb85620921a8a120fe22edbccae708f4f34end
4e3cdb85620921a8a120fe22edbccae708f4f34end <p>Use this directive to disable the module instead of
4e3cdb85620921a8a120fe22edbccae708f4f34end commenting out all the <code class="directive"><a href="#rewriterule">RewriteRule</a></code> directives!</p>
81785f72c9d133aef57ad6b02f248345d90239aapoirier
81785f72c9d133aef57ad6b02f248345d90239aapoirier <p>Note that rewrite configurations are not
5ae30adbe59946de742ab0cd6be3b7457471a698takashi inherited by virtual hosts. This means that you need to have a
4e3cdb85620921a8a120fe22edbccae708f4f34end <code>RewriteEngine on</code> directive for each virtual host
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem in which you wish to use rewrite rules.</p>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p><code class="directive">RewriteMap</code> directives of the type <code>prg</code>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive are not started during server initialization if they're defined in a
06ba4a61654b3763ad65f52283832ebf058fdf1cslive context that does not have <code class="directive">RewriteEngine</code> set to
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>on</code></p>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</div>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
97a9a944b5887e91042b019776c41d5dd74557aferikabele<div class="directive-section"><h2><a name="RewriteLog" id="RewriteLog">RewriteLog</a> <a name="rewritelog" id="rewritelog">Directive</a></h2>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<table class="directive">
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets the name of the file used for logging rewrite engine
06ba4a61654b3763ad65f52283832ebf058fdf1csliveprocessing</td></tr>
81785f72c9d133aef57ad6b02f248345d90239aapoirier<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteLog <em>file-path</em></code></td></tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<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>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem</table>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>The <code class="directive">RewriteLog</code> directive sets the name
06ba4a61654b3763ad65f52283832ebf058fdf1cslive of the file to which the server logs any rewriting actions it
06ba4a61654b3763ad65f52283832ebf058fdf1cslive performs. If the name does not begin with a slash
97a9a944b5887e91042b019776c41d5dd74557aferikabele ('<code>/</code>') then it is assumed to be relative to the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>Server Root</em>. The directive should occur only once per
06ba4a61654b3763ad65f52283832ebf058fdf1cslive server config.</p>
5ae30adbe59946de742ab0cd6be3b7457471a698takashi
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<div class="note"> To disable the logging of
06ba4a61654b3763ad65f52283832ebf058fdf1cslive rewriting actions it is not recommended to set
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <em>Filename</em> to <code>/dev/null</code>, because
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem although the rewriting engine does not then output to a
22d5d84393d960a2027f472036f3fee15d7dbce9nd logfile it still creates the logfile output internally.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong>This will slow down the server with no advantage
06ba4a61654b3763ad65f52283832ebf058fdf1cslive to the administrator!</strong> To disable logging either
06ba4a61654b3763ad65f52283832ebf058fdf1cslive remove or comment out the <code class="directive">RewriteLog</code>
97a9a944b5887e91042b019776c41d5dd74557aferikabele directive or use <code>RewriteLogLevel 0</code>!
81785f72c9d133aef57ad6b02f248345d90239aapoirier</div>
5ae30adbe59946de742ab0cd6be3b7457471a698takashi
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<div class="note"><h3>Security</h3>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1csliveSee the <a href="/misc/security_tips.html">Apache Security Tips</a>
06ba4a61654b3763ad65f52283832ebf058fdf1cslivedocument for details on how your security could be compromised if the
06ba4a61654b3763ad65f52283832ebf058fdf1cslivedirectory where logfiles are stored is writable by anyone other than
06ba4a61654b3763ad65f52283832ebf058fdf1cslivethe user that starts the server.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</div>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<div class="example"><h3>Example</h3><p><code>
81785f72c9d133aef57ad6b02f248345d90239aapoirierRewriteLog "/usr/local/var/apache/logs/rewrite.log"
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</code></p></div>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<div class="directive-section"><h2><a name="RewriteLogLevel" id="RewriteLogLevel">RewriteLogLevel</a> <a name="rewriteloglevel" id="rewriteloglevel">Directive</a></h2>
97a9a944b5887e91042b019776c41d5dd74557aferikabele<table class="directive">
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets the verbosity of the log file used by the rewrite
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluemengine</td></tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteLogLevel <em>Level</em></code></td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>RewriteLogLevel 0</code></td></tr>
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl</table>
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl <p>The <code class="directive">RewriteLogLevel</code> directive sets the
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl verbosity level of the rewriting logfile. The default level 0
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl means no logging, while 9 or more means that practically all
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl actions are logged.</p>
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl
9335f6d807d76d60e54af4ededdebebddb3e3d13noodl <p>To disable the logging of rewriting actions simply set
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>Level</em> to 0. This disables all rewrite action
22d5d84393d960a2027f472036f3fee15d7dbce9nd logs.</p>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<div class="note"> Using a high value for
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>Level</em> will slow down your Apache server
06ba4a61654b3763ad65f52283832ebf058fdf1cslive dramatically! Use the rewriting logfile at a
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>Level</em> greater than 2 only for debugging!
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<div class="example"><h3>Example</h3><p><code>
97a9a944b5887e91042b019776c41d5dd74557aferikabeleRewriteLogLevel 3
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</code></p></div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<div class="directive-section"><h2><a name="RewriteMap" id="RewriteMap">RewriteMap</a> <a name="rewritemap" id="rewritemap">Directive</a></h2>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<table class="directive">
97a9a944b5887e91042b019776c41d5dd74557aferikabele<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>
81785f72c9d133aef57ad6b02f248345d90239aapoirier</code></td></tr>
5ae30adbe59946de742ab0cd6be3b7457471a698takashi<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
5ae30adbe59946de742ab0cd6be3b7457471a698takashi<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>The choice of different dbm types is available in
81785f72c9d133aef57ad6b02f248345d90239aapoirierApache 2.0.41 and later</td></tr>
5ae30adbe59946de742ab0cd6be3b7457471a698takashi</table>
5ae30adbe59946de742ab0cd6be3b7457471a698takashi <p>The <code class="directive">RewriteMap</code> directive defines a
5ae30adbe59946de742ab0cd6be3b7457471a698takashi <em>Rewriting Map</em> which can be used inside rule
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem substitution strings by the mapping-functions to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive insert/substitute fields through a key lookup. The source of
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd this lookup can be of various types.</p>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <p>The <a id="mapfunc" name="mapfunc"><em>MapName</em></a> is
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd the name of the map and will be used to specify a
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd mapping-function for the substitution strings of a rewriting
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd rule via one of the following constructs:</p>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <p class="indent">
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <strong><code>${</code> <em>MapName</em> <code>:</code>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <em>LookupKey</em> <code>}</code><br />
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <code>${</code> <em>MapName</em> <code>:</code>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <em>LookupKey</em> <code>|</code> <em>DefaultValue</em>
81785f72c9d133aef57ad6b02f248345d90239aapoirier <code>}</code></strong>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>When such a construct occurs, the map <em>MapName</em> is
06ba4a61654b3763ad65f52283832ebf058fdf1cslive consulted and the key <em>LookupKey</em> is looked-up. If the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive key is found, the map-function construct is substituted by
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>SubstValue</em>. If the key is not found then it is
06ba4a61654b3763ad65f52283832ebf058fdf1cslive substituted by <em>DefaultValue</em> or by the empty string
06ba4a61654b3763ad65f52283832ebf058fdf1cslive if no <em>DefaultValue</em> was specified.</p>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>For example, you might define a
4c36c711036219c80d5517d35be68a4769c15291slive <code class="directive">RewriteMap</code> as:</p>
4c36c711036219c80d5517d35be68a4769c15291slive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <div class="example"><p><code>
4c36c711036219c80d5517d35be68a4769c15291slive RewriteMap examplemap txt:/path/to/file/map.txt
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd </code></p></div>
fc9f416faa11879811f17d6efadedbf81cfd52a1covener
fc9f416faa11879811f17d6efadedbf81cfd52a1covener <p>You would then be able to use this map in a
fc9f416faa11879811f17d6efadedbf81cfd52a1covener <code class="directive">RewriteRule</code> as follows:</p>
fc9f416faa11879811f17d6efadedbf81cfd52a1covener
fc9f416faa11879811f17d6efadedbf81cfd52a1covener <div class="example"><p><code>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd RewriteRule ^/ex/(.*) ${examplemap:$1}
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd </code></p></div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <p>The following combinations for <em>MapType</em> and
627c978514c54179736d152923478be7c8707f9bnd <em>MapSource</em> can be used:</p>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <ul>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <li>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <strong>Standard Plain Text</strong><br />
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd MapType: <code>txt</code>, MapSource: Unix filesystem
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd path to valid regular file
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele <p>This is the standard rewriting map feature where the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>MapSource</em> is a plain ASCII file containing
06ba4a61654b3763ad65f52283832ebf058fdf1cslive either blank lines, comment lines (starting with a '#'
06ba4a61654b3763ad65f52283832ebf058fdf1cslive character) or pairs like the following - one per
06ba4a61654b3763ad65f52283832ebf058fdf1cslive line.</p>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <p class="indent">
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <strong><em>MatchingKey</em>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <em>SubstValue</em></strong>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd </p>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="example"><h3>Example</h3><pre>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd##
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd## map.txt -- rewriting map
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd##
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4ndRalf.S.Engelschall rse # Bastard Operator From Hell
06ba4a61654b3763ad65f52283832ebf058fdf1csliveMr.Joe.Average joe # Mr. Average
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</pre></div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<div class="example"><p><code>
06ba4a61654b3763ad65f52283832ebf058fdf1csliveRewriteMap real-to-user txt:/path/to/file/map.txt
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</code></p></div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </li>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong>Randomized Plain Text</strong><br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive MapType: <code>rnd</code>, MapSource: Unix filesystem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive path to valid regular file
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>This is identical to the Standard Plain Text variant
06ba4a61654b3763ad65f52283832ebf058fdf1cslive above but with a special post-processing feature: After
06ba4a61654b3763ad65f52283832ebf058fdf1cslive looking up a value it is parsed according to contained
97a9a944b5887e91042b019776c41d5dd74557aferikabele ``<code>|</code>'' characters which have the meaning of
06ba4a61654b3763ad65f52283832ebf058fdf1cslive ``or''. In other words they indicate a set of
97a9a944b5887e91042b019776c41d5dd74557aferikabele alternatives from which the actual returned value is
06ba4a61654b3763ad65f52283832ebf058fdf1cslive chosen randomly. For example, you might use the following map
06ba4a61654b3763ad65f52283832ebf058fdf1cslive file and directives to provide a random load balancing between
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem several back-end server, via a reverse-proxy. Images are sent
06ba4a61654b3763ad65f52283832ebf058fdf1cslive to one of the servers in the 'static' pool, while everything
06ba4a61654b3763ad65f52283832ebf058fdf1cslive else is sent to one of the 'dynamic' pool.</p>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <p>Example:</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele<div class="example"><h3>Rewrite map file</h3><pre>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive##
97a9a944b5887e91042b019776c41d5dd74557aferikabele## map.txt -- rewriting map
97a9a944b5887e91042b019776c41d5dd74557aferikabele##
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4ndstatic www1|www2|www3|www4
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nddynamic www5|www6
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</pre></div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="example"><h3>Configuration directives</h3><p><code>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4ndRewriteMap servers rnd:/path/to/file/map.txt<br />
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<br />
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4ndRewriteRule ^/(.*\.(png|gif|jpg)) http://${servers:static}/$1
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd[NC,P,L]<br />
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4ndRewriteRule ^/(.*) http://${servers:dynamic}/$1 [P,L]
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</code></p></div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd </li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong>Hash File</strong><br /> MapType:
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>dbm[=<em>type</em>]</code>, MapSource: Unix filesystem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive path to valid regular file
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>Here the source is a binary format DBM file containing
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the same contents as a <em>Plain Text</em> format file, but
06ba4a61654b3763ad65f52283832ebf058fdf1cslive in a special representation which is optimized for really
97a9a944b5887e91042b019776c41d5dd74557aferikabele fast lookups. The <em>type</em> can be sdbm, gdbm, ndbm, or
06ba4a61654b3763ad65f52283832ebf058fdf1cslive db depending on <a href="/install.html#dbm">compile-time
06ba4a61654b3763ad65f52283832ebf058fdf1cslive settings</a>. If the <em>type</em> is omitted, the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive compile-time default will be chosen.</p>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>To create a dbm file from a source text file, use the <a href="/programs/httxt2dbm.html">httxt2dbm</a> utility.</p>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<div class="example"><p><code>
97a9a944b5887e91042b019776c41d5dd74557aferikabele$ httxt2dbm -i mapfile.txt -o mapfile.map
97a9a944b5887e91042b019776c41d5dd74557aferikabele</code></p></div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd </li>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <li>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <strong>Internal Function</strong><br />
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd MapType: <code>int</code>, MapSource: Internal Apache
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd function
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <p>Here, the source is an internal Apache function.
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd Currently you cannot create your own, but the following
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd functions already exist:</p>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <ul>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <li><strong>toupper</strong>:<br />
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd Converts the key to all upper case.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li><strong>tolower</strong>:<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive Converts the key to all lower case.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li><strong>escape</strong>:<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive Translates special characters in the key to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive hex-encodings.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li><strong>unescape</strong>:<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive Translates hex-encodings in the key back to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive special characters.</li>
97a9a944b5887e91042b019776c41d5dd74557aferikabele </ul>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </li>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong>External Rewriting Program</strong><br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive MapType: <code>prg</code>, MapSource: Unix filesystem
97a9a944b5887e91042b019776c41d5dd74557aferikabele path to valid regular file
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p>Here the source is a program, not a map file. To
06ba4a61654b3763ad65f52283832ebf058fdf1cslive create it you can use a language of your choice, but
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the result has to be an executable program (either
06ba4a61654b3763ad65f52283832ebf058fdf1cslive object-code or a script with the magic cookie trick
06ba4a61654b3763ad65f52283832ebf058fdf1cslive '<code>#!/path/to/interpreter</code>' as the first
06ba4a61654b3763ad65f52283832ebf058fdf1cslive line).</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen <p>This program is started once, when the Apache server
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen is started, and then communicates with the rewriting engine
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen via its <code>stdin</code> and <code>stdout</code>
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen file-handles. For each map-function lookup it will
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen receive the key to lookup as a newline-terminated string
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen on <code>stdin</code>. It then has to give back the
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen looked-up value as a newline-terminated string on
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen <code>stdout</code> or the four-character string
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen ``<code>NULL</code>'' if it fails (<em>i.e.</em>, there
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen is no corresponding value for the given key).</p>
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen
8ac3ff7008df949c096f9cd8f769c7893594f61fnd <p>This feature utilizes the <code>rewrite-map</code> mutex,
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen which is required for reliable communication with the program.
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen The mutex mechanism and lock file can be configured with the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code class="directive"><a href="/mod/core.html#mutex">Mutex</a></code> directive.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>External rewriting programs are not started if they're defined in a
06ba4a61654b3763ad65f52283832ebf058fdf1cslive context that does not have <code class="directive">RewriteEngine</code> set to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>on</code></p>.
97a9a944b5887e91042b019776c41d5dd74557aferikabele
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>A trivial program which will implement a 1:1 map (<em>i.e.</em>,
81785f72c9d133aef57ad6b02f248345d90239aapoirier key == value) could be:</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<div class="example"><pre>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive#!/usr/bin/perl
06ba4a61654b3763ad65f52283832ebf058fdf1cslive$| = 1;
06ba4a61654b3763ad65f52283832ebf058fdf1cslivewhile (&lt;STDIN&gt;) {
06ba4a61654b3763ad65f52283832ebf058fdf1cslive # ...put here any transformations or lookups...
06ba4a61654b3763ad65f52283832ebf058fdf1cslive print $_;
97a9a944b5887e91042b019776c41d5dd74557aferikabele}
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</pre></div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele <p>But be very careful:</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele <ol>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>``<em>Keep it simple, stupid</em>'' (KISS).
06ba4a61654b3763ad65f52283832ebf058fdf1cslive If this program hangs, it will cause Apache to hang
06ba4a61654b3763ad65f52283832ebf058fdf1cslive when trying to use the relevant rewrite rule.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>A common mistake is to use buffered I/O on
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>stdout</code>. Avoid this, as it will cause a deadloop!
97a9a944b5887e91042b019776c41d5dd74557aferikabele ``<code>$|=1</code>'' is used above, to prevent this.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </ol>
97a9a944b5887e91042b019776c41d5dd74557aferikabele </li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <p><strong>SQL Query</strong><br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive MapType: <code>dbd</code> or <code>fastdbd</code>,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive MapSource: An SQL SELECT statement that takes a single
06ba4a61654b3763ad65f52283832ebf058fdf1cslive argument and returns a single value.</p>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <p>This uses <code class="module"><a href="/mod/mod_dbd.html">mod_dbd</a></code> to implement a rewritemap
06ba4a61654b3763ad65f52283832ebf058fdf1cslive by lookup in an SQL database. There are two forms:
81785f72c9d133aef57ad6b02f248345d90239aapoirier <code>fastdbd</code> caches database lookups internally,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>dbd</code> doesn't. So <code>dbd</code> incurs a
06ba4a61654b3763ad65f52283832ebf058fdf1cslive performance penalty but responds immediately if the database
06ba4a61654b3763ad65f52283832ebf058fdf1cslive contents are updated, while <code>fastdbd</code> is more
06ba4a61654b3763ad65f52283832ebf058fdf1cslive efficient but won't re-read database contents until server
06ba4a61654b3763ad65f52283832ebf058fdf1cslive restart.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>If a query returns more than one row, a random row from
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the result set is used.</p>
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen<div class="example"><h3>Example</h3><p><code>
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowenRewriteMap myquery "fastdbd:SELECT destination FROM rewrite WHERE source = %s"
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen</code></p></div>
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen </li>
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen </ul>
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen <p>The <code class="directive">RewriteMap</code> directive can occur more than
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen once. For each mapping-function use one
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code class="directive">RewriteMap</code> directive to declare its rewriting
06ba4a61654b3763ad65f52283832ebf058fdf1cslive mapfile. While you cannot <strong>declare</strong> a map in
06ba4a61654b3763ad65f52283832ebf058fdf1cslive per-directory context it is of course possible to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong>use</strong> this map in per-directory context. </p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<div class="note"><h3>Note</h3> For plain text and DBM format files the
97a9a944b5887e91042b019776c41d5dd74557aferikabelelooked-up keys are cached in-core until the <code>mtime</code> of the
06ba4a61654b3763ad65f52283832ebf058fdf1cslivemapfile changes or the server does a restart. This way you can have
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowenmap-functions in rules which are used for <strong>every</strong>
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowenrequest. This is no problem, because the external lookup only happens
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowenonce!
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen</div>
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen
97a9a944b5887e91042b019776c41d5dd74557aferikabele</div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<div class="directive-section"><h2><a name="RewriteOptions" id="RewriteOptions">RewriteOptions</a> <a name="rewriteoptions" id="rewriteoptions">Directive</a></h2>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<table class="directive">
97a9a944b5887e91042b019776c41d5dd74557aferikabele<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets some special options for the rewrite engine</td></tr>
1578daeec017d3bb20cecdcdc3b0261c999730d5slive<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteOptions <var>Options</var></code></td></tr>
1578daeec017d3bb20cecdcdc3b0261c999730d5slive<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
1578daeec017d3bb20cecdcdc3b0261c999730d5slive<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
1578daeec017d3bb20cecdcdc3b0261c999730d5slive<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
1578daeec017d3bb20cecdcdc3b0261c999730d5slive<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
1578daeec017d3bb20cecdcdc3b0261c999730d5slive<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td><code>MaxRedirects</code> is no longer available in version 2.1 and
1578daeec017d3bb20cecdcdc3b0261c999730d5slivelater</td></tr>
1578daeec017d3bb20cecdcdc3b0261c999730d5slive</table>
ab6f5669a4cb16dbff7d791d434ba1b9c9b50928nd
9f7f8f89dfb9115b0b9493049a6ca1ecd8508242rbowen <p>The <code class="directive">RewriteOptions</code> directive sets some
06ba4a61654b3763ad65f52283832ebf058fdf1cslive special options for the current per-server or per-directory
9f7f8f89dfb9115b0b9493049a6ca1ecd8508242rbowen configuration. The <em>Option</em> string can currently
06ba4a61654b3763ad65f52283832ebf058fdf1cslive only be one of the following:</p>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
9f7f8f89dfb9115b0b9493049a6ca1ecd8508242rbowen <dl>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <dt><code>inherit</code></dt>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dd>This forces the current configuration to inherit the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive configuration of the parent. In per-virtual-server context,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive this means that the maps, conditions and rules of the main
97a9a944b5887e91042b019776c41d5dd74557aferikabele server are inherited. In per-directory context this means
06ba4a61654b3763ad65f52283832ebf058fdf1cslive that conditions and rules of the parent directory's
81785f72c9d133aef57ad6b02f248345d90239aapoirier <code>.htaccess</code> configuration or
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code class="directive"><a href="/mod/core.html#directory">&lt;Directory&gt;</a></code>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem sections are inherited. The inherited rules are virtually copied
06ba4a61654b3763ad65f52283832ebf058fdf1cslive to the section where this directive is being used. If used in
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem combination with local rules, the inherited rules are copied behind
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the local rules. The position of this directive - below or above
06ba4a61654b3763ad65f52283832ebf058fdf1cslive of local rules - has no influence on this behavior. If local
97a9a944b5887e91042b019776c41d5dd74557aferikabele rules forced the rewriting to stop, the inherited rules won't
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem be processed.</dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </dl>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem</div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
97a9a944b5887e91042b019776c41d5dd74557aferikabele<div class="directive-section"><h2><a name="RewriteRule" id="RewriteRule">RewriteRule</a> <a name="rewriterule" id="rewriterule">Directive</a></h2>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<table class="directive">
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Defines rules for the rewriting engine</td></tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteRule
97a9a944b5887e91042b019776c41d5dd74557aferikabele <em>Pattern</em> <em>Substitution</em> [<em>flags</em>]</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>
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">RewriteRule</code> directive is the real
97a9a944b5887e91042b019776c41d5dd74557aferikabele rewriting workhorse. The directive can occur more than once,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive with each instance defining a single rewrite rule. The
81785f72c9d133aef57ad6b02f248345d90239aapoirier order in which these rules are defined is important - this is the order
06ba4a61654b3763ad65f52283832ebf058fdf1cslive in which they will be applied at run-time.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p><a id="patterns" name="patterns"><em>Pattern</em></a> is
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem a perl compatible <a id="regexp" name="regexp">regular
06ba4a61654b3763ad65f52283832ebf058fdf1cslive expression</a>. On the first RewriteRule it is applied to the (%-encoded)
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <a href="/directive-dict.html#Syntax">URL-path</a> of the request;
06ba4a61654b3763ad65f52283832ebf058fdf1cslive subsequent patterns are applied to the output of the last matched
06ba4a61654b3763ad65f52283832ebf058fdf1cslive RewriteRule.</p>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<div class="note"><h3>What is matched?</h3>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p>The <em>Pattern</em> will initially be matched against the part of the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive URL after the hostname and port, and before the query string.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>When the RewriteRule appears in per-directory (htaccess) context, the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>Pattern</em> is matched against what remains of the URL after removing
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the prefix that lead Apache to the current rules (see the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code class="directive"><a href="#rewritebase">RewriteBase</a></code>). The removed prefix
a4d04b8c74044c58bd4182028a1408d936c95951covener always ends with a slash, meaning the matching occurs against a string which
06ba4a61654b3763ad65f52283832ebf058fdf1cslive never has a leading slash. A <em>Pattern</em> with <code>^/</code> never
63ef912b1ba017169e2623b3ad868aaef8d928e4covener matches in per-directory context.</p>
fc9f416faa11879811f17d6efadedbf81cfd52a1covener
fc9f416faa11879811f17d6efadedbf81cfd52a1covener <p>If you wish to match against the hostname, port, or query string, use a
81785f72c9d133aef57ad6b02f248345d90239aapoirier <code class="directive"><a href="#rewritecond">RewriteCond</a></code> with the
a4d04b8c74044c58bd4182028a1408d936c95951covener <code>%{HTTP_HOST}</code>, <code>%{SERVER_PORT}</code>, or
a4d04b8c74044c58bd4182028a1408d936c95951covener <code>%{QUERY_STRING}</code> variables respectively. If you wish to
fc9f416faa11879811f17d6efadedbf81cfd52a1covener match against the full URL-path in a per-directory (htaccess) RewriteRule,
97a9a944b5887e91042b019776c41d5dd74557aferikabele use the <code>%{REQUEST_URI}</code> variable.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>For some hints on <a class="glossarylink" href="/glossary.html#regex" title="see glossary">regular
06ba4a61654b3763ad65f52283832ebf058fdf1cslive expressions</a>, see
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the <a href="/rewrite/intro.html#regex">mod_rewrite
97a9a944b5887e91042b019776c41d5dd74557aferikabele Introduction</a>.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>In mod_rewrite, the NOT character
06ba4a61654b3763ad65f52283832ebf058fdf1cslive ('<code>!</code>') is also available as a possible pattern
06ba4a61654b3763ad65f52283832ebf058fdf1cslive prefix. This enables you to negate a pattern; to say, for instance:
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem ``<em>if the current URL does <strong>NOT</strong> match this
81785f72c9d133aef57ad6b02f248345d90239aapoirier pattern</em>''. This can be used for exceptional cases, where
5ae30adbe59946de742ab0cd6be3b7457471a698takashi it is easier to match the negative pattern, or as a last
06ba4a61654b3763ad65f52283832ebf058fdf1cslive default rule.</p>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<div class="note"><h3>Note</h3>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluemWhen using the NOT character to negate a pattern, you cannot include
06ba4a61654b3763ad65f52283832ebf058fdf1cslivegrouped wildcard parts in that pattern. This is because, when the
81785f72c9d133aef57ad6b02f248345d90239aapoirierpattern does NOT match (ie, the negation matches), there are no
81785f72c9d133aef57ad6b02f248345d90239aapoiriercontents for the groups. Thus, if negated patterns are used, you
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluemcannot use <code>$N</code> in the substitution string!
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>The <a id="rhs" name="rhs"><em>Substitution</em></a> of a
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd rewrite rule is the string that replaces the original URL-path that
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd was matched by <em>Pattern</em>. The <em>Substitution</em> may
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd be a:</p>
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd <dl>
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd <dt>file-system path</dt>
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd <dd>Designates the location on the file-system of the resource
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd to be delivered to the client.</dd>
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd <dt>URL-path</dt>
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd <dd>A <code class="directive"><a href="/mod/core.html#documentroot">DocumentRoot</a></code>-relative path to the
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd resource to be served. Note that <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code>
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd tries to guess whether you have specified a file-system path
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd or a URL-path by checking to see if the first segment of the
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd path exists at the root of the file-system. For example, if
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd you specify a <em>Substitution</em> string of
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd <code>/www/file.html</code>, then this will be treated as a
06ba4a61654b3763ad65f52283832ebf058fdf1cslive URL-path <em>unless</em> a directory named <code>www</code>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive exists at the root or your file-system, in which case it will
06ba4a61654b3763ad65f52283832ebf058fdf1cslive be treated as a file-system path. If you wish other
06ba4a61654b3763ad65f52283832ebf058fdf1cslive URL-mapping directives (such as <code class="directive"><a href="/mod/mod_alias.html#alias">Alias</a></code>) to be applied to the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive resulting URL-path, use the <code>[PT]</code> flag as
06ba4a61654b3763ad65f52283832ebf058fdf1cslive described below.</dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dt>Absolute URL</dt>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dd>If an absolute URL is specified,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> checks to see whether the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive hostname matches the current host. If it does, the scheme and
06ba4a61654b3763ad65f52283832ebf058fdf1cslive hostname are stripped out and the resulting path is treated as
06ba4a61654b3763ad65f52283832ebf058fdf1cslive a URL-path. Otherwise, an external redirect is performed for
97a9a944b5887e91042b019776c41d5dd74557aferikabele the given URL. To force an external redirect back to the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive current host, see the <code>[R]</code> flag below.</dd>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <dt><code>-</code> (dash)</dt>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <dd>A dash indicates that no substitution should be performed
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd (the existing path is passed through untouched). This is used
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd when a flag (see below) needs to be applied without changing
0203b896e484dfb877111aceffb812401d0f216and the path.</dd>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd </dl>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <p>In addition to plain text, the <em>Substition</em> string can include</p>
844def494f17cb1ab0983427d5c3939e1a03ff8cnd
0203b896e484dfb877111aceffb812401d0f216and <ol>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <li>back-references (<code>$N</code>) to the RewriteRule
06ba4a61654b3763ad65f52283832ebf058fdf1cslive pattern</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>back-references (<code>%N</code>) to the last matched
81785f72c9d133aef57ad6b02f248345d90239aapoirier RewriteCond pattern</li>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>server-variables as in rule condition test-strings
0203b896e484dfb877111aceffb812401d0f216and (<code>%{VARNAME}</code>)</li>
0203b896e484dfb877111aceffb812401d0f216and
0203b896e484dfb877111aceffb812401d0f216and <li><a href="#mapfunc">mapping-function</a> calls
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem (<code>${mapname:key|default}</code>)</li>
0203b896e484dfb877111aceffb812401d0f216and </ol>
0203b896e484dfb877111aceffb812401d0f216and
0203b896e484dfb877111aceffb812401d0f216and <p>Back-references are identifiers of the form
a4d04b8c74044c58bd4182028a1408d936c95951covener <code>$</code><strong>N</strong>
a4d04b8c74044c58bd4182028a1408d936c95951covener (<strong>N</strong>=0..9), which will be replaced
a4d04b8c74044c58bd4182028a1408d936c95951covener by the contents of the <strong>N</strong>th group of the
a4d04b8c74044c58bd4182028a1408d936c95951covener matched <em>Pattern</em>. The server-variables are the same
a4d04b8c74044c58bd4182028a1408d936c95951covener as for the <em>TestString</em> of a <code>RewriteCond</code>
a4d04b8c74044c58bd4182028a1408d936c95951covener directive. The mapping-functions come from the
a4d04b8c74044c58bd4182028a1408d936c95951covener <code>RewriteMap</code> directive and are explained there.
a4d04b8c74044c58bd4182028a1408d936c95951covener These three types of variables are expanded in the order above.</p>
a4d04b8c74044c58bd4182028a1408d936c95951covener
0203b896e484dfb877111aceffb812401d0f216and <p>As already mentioned, all rewrite rules are
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd applied to the <em>Substitution</em> (in the order in which
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd they are defined
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd in the config file). The URL is <strong>completely
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd replaced</strong> by the <em>Substitution</em> and the
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd rewriting process continues until all rules have been applied,
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd or it is explicitly terminated by a
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <code><strong>L</strong></code> flag.</p>
96147932f199be4ad038778e702c13a2f79051c0slive
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <div class="note"><h3>Modifying the Query String</h3>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <p>By default, the query string is passed through unchanged. You
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd can, however, create URLs in the substitution string containing
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd a query string part. Simply use a question mark inside the
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd substitution string to indicate that the following text should
06ba4a61654b3763ad65f52283832ebf058fdf1cslive be re-injected into the query string. When you want to erase an
81785f72c9d133aef57ad6b02f248345d90239aapoirier existing query string, end the substitution string with just a
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem question mark. To combine new and old query strings, use the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>[QSA]</code> flag.</p>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem </div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
630c456b6461158be6cc5c5483735e27b13b4ad5nd
630c456b6461158be6cc5c5483735e27b13b4ad5nd
a4d04b8c74044c58bd4182028a1408d936c95951covener <p>Additionally you can set special <a name="rewriteflags" id="rewriteflags">actions</a> to be performed by
8c8c2e71c84babf0e8c4b35819c7c5b3be014cfenoodl appending <strong><code>[</code><em>flags</em><code>]</code></strong>
8c8c2e71c84babf0e8c4b35819c7c5b3be014cfenoodl as the third argument to the <code>RewriteRule</code>
8c8c2e71c84babf0e8c4b35819c7c5b3be014cfenoodl directive. <em>Flags</em> is a comma-separated list, surround by square
06ba4a61654b3763ad65f52283832ebf058fdf1cslive brackets, of any of the following flags: </p>
96147932f199be4ad038778e702c13a2f79051c0slive
96147932f199be4ad038778e702c13a2f79051c0slive <dl>
96147932f199be4ad038778e702c13a2f79051c0slive <dt>'<code>B</code>' (escape backreferences)</dt>
96147932f199be4ad038778e702c13a2f79051c0slive <dd><p>Apache has to unescape URLs before mapping them,
96147932f199be4ad038778e702c13a2f79051c0slive so backreferences will be unescaped at the time they are applied.
96147932f199be4ad038778e702c13a2f79051c0slive Using the B flag, non-alphanumeric characters in backreferences
96147932f199be4ad038778e702c13a2f79051c0slive will be escaped. For example, consider the rule:</p>
96147932f199be4ad038778e702c13a2f79051c0slive <div class="example"><p><code>
96147932f199be4ad038778e702c13a2f79051c0slive RewriteRule ^(/.*)$ /index.php?show=$1
70f2730533c8592263435354e66d9dbaf4d6361bslive </code></p></div>
70f2730533c8592263435354e66d9dbaf4d6361bslive <p>This will map <code>/C++</code> to
1093a264c81aa1041581ab059905fb8f7cdfc5e2rbowen <code>/index.php?show=/C++</code>. But it will also map
70f2730533c8592263435354e66d9dbaf4d6361bslive <code>/C%2b%2b</code> to <code>/index.php?show=/C++</code>, because
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the <code>%2b</code> has been unescaped. With the B flag, it will
5ae30adbe59946de742ab0cd6be3b7457471a698takashi instead map to <code>/index.php?show=/C%2b%2b</code>.</p>
81785f72c9d133aef57ad6b02f248345d90239aapoirier <p>This escaping is particularly necessary in a proxy situation,
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem when the backend may break if presented with an unescaped URL.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dt>'<code>chain|C</code>'
06ba4a61654b3763ad65f52283832ebf058fdf1cslive (chained with next rule)</dt><dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive This flag chains the current rule with the next rule
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem (which itself can be chained with the following rule,
81785f72c9d133aef57ad6b02f248345d90239aapoirier and so on). This has the following effect: if a rule
81785f72c9d133aef57ad6b02f248345d90239aapoirier matches, then processing continues as usual -
81785f72c9d133aef57ad6b02f248345d90239aapoirier the flag has no effect. If the rule does
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <strong>not</strong> match, then all following chained
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem rules are skipped. For instance, it can be used to remove the
97a9a944b5887e91042b019776c41d5dd74557aferikabele ``<code>.www</code>'' part, inside a per-directory rule set,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive when you let an external redirect happen (where the
96147932f199be4ad038778e702c13a2f79051c0slive ``<code>.www</code>'' part should not occur!).</dd>
96147932f199be4ad038778e702c13a2f79051c0slive
96147932f199be4ad038778e702c13a2f79051c0slive <dt>'<code>cookie|CO=</code><em>NAME</em>:<em>VAL</em>:<em>domain</em>[:<em>lifetime</em>[:<em>path</em>[:<em>secure</em>[:<em>httponly</em>]]]]'
96147932f199be4ad038778e702c13a2f79051c0slive (set cookie)</dt><dd>
96147932f199be4ad038778e702c13a2f79051c0slive This sets a cookie in the client's browser. The cookie's name
96147932f199be4ad038778e702c13a2f79051c0slive is specified by <em>NAME</em> and the value is
96147932f199be4ad038778e702c13a2f79051c0slive <em>VAL</em>. The <em>domain</em> field is the domain of the
96147932f199be4ad038778e702c13a2f79051c0slive cookie, such as '.apache.org', the optional <em>lifetime</em>
96147932f199be4ad038778e702c13a2f79051c0slive is the lifetime of the cookie in minutes (0 means expires at end
96147932f199be4ad038778e702c13a2f79051c0slive of session), and the optional
96147932f199be4ad038778e702c13a2f79051c0slive <em>path</em> is the path of the cookie. If <em>secure</em>
96147932f199be4ad038778e702c13a2f79051c0slive is set to 'secure', 'true' or '1', the cookie is only transmitted via secured
81785f72c9d133aef57ad6b02f248345d90239aapoirier connections. If <em>httponly</em> is set to 'HttpOnly', 'true' or '1', the
96147932f199be4ad038778e702c13a2f79051c0slive <code>HttpOnly</code> flag is used, making the cookie inaccessible
96147932f199be4ad038778e702c13a2f79051c0slive to JavaScript code on browsers that support this feature.</dd>
96147932f199be4ad038778e702c13a2f79051c0slive
96147932f199be4ad038778e702c13a2f79051c0slive <dt>'<code>discardpathinfo|DPI'
e00def5e805da9a73b72ad25dac664f0c8c36c2end (discard PATH_INFO)</code></dt><dd>
96147932f199be4ad038778e702c13a2f79051c0slive <p>This flag is available from 2.2.12</p>
96147932f199be4ad038778e702c13a2f79051c0slive <p>In per-directory context, the URI each <code class="directive">RewriteRule</code>
96147932f199be4ad038778e702c13a2f79051c0slive compares against is the concatenation of the current values of the URI
96147932f199be4ad038778e702c13a2f79051c0slive and PATH_INFO.</p>
96147932f199be4ad038778e702c13a2f79051c0slive
96147932f199be4ad038778e702c13a2f79051c0slive <p>The current URI can be the initial URI as requested by the client, the
96147932f199be4ad038778e702c13a2f79051c0slive result of a previous round of mod_rewrite processing, or the result of
96147932f199be4ad038778e702c13a2f79051c0slive a prior rule in the current round of mod_rewrite processing.</p>
96147932f199be4ad038778e702c13a2f79051c0slive
96147932f199be4ad038778e702c13a2f79051c0slive <p>In contrast, the PATH_INFO that is appended to the URI before each
96147932f199be4ad038778e702c13a2f79051c0slive rule reflects only the value of PATH_INFO before this round of
96147932f199be4ad038778e702c13a2f79051c0slive mod_rewrite processing. As a consequence, if large portions
96147932f199be4ad038778e702c13a2f79051c0slive of the URI are matched and copied into a substitution in multiple
96147932f199be4ad038778e702c13a2f79051c0slive <code class="directive">RewriteRule</code> directives, without regard for
96147932f199be4ad038778e702c13a2f79051c0slive which parts of the URI came from the current PATH_INFO, the final
96147932f199be4ad038778e702c13a2f79051c0slive URI may have multiple copies of PATH_INFO appended to it.</p>
96147932f199be4ad038778e702c13a2f79051c0slive
96147932f199be4ad038778e702c13a2f79051c0slive <p>Use this flag on any substitution where the PATH_INFO that resulted
96147932f199be4ad038778e702c13a2f79051c0slive from the previous mapping of this request to the filesystem is not of
96147932f199be4ad038778e702c13a2f79051c0slive interest. This flag permanently forgets the PATH_INFO established
96147932f199be4ad038778e702c13a2f79051c0slive before this round of mod_rewrite processing began. PATH_INFO will
96147932f199be4ad038778e702c13a2f79051c0slive not be recalculated until the current round of mod_rewrite processing
96147932f199be4ad038778e702c13a2f79051c0slive completes. Subsequent rules during this round of processing will see
96147932f199be4ad038778e702c13a2f79051c0slive only the direct result of substitutions, without any PATH_INFO
96147932f199be4ad038778e702c13a2f79051c0slive appended.</p></dd>
96147932f199be4ad038778e702c13a2f79051c0slive
96147932f199be4ad038778e702c13a2f79051c0slive <dt>
96147932f199be4ad038778e702c13a2f79051c0slive '<code>env|E=</code><em>VAR</em>:<em>VAL</em>'
96147932f199be4ad038778e702c13a2f79051c0slive (set environment variable)</dt><dd>
96147932f199be4ad038778e702c13a2f79051c0slive This forces an environment variable named <em>VAR</em> to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive be set to the value <em>VAL</em>, where <em>VAL</em> can
06ba4a61654b3763ad65f52283832ebf058fdf1cslive contain regexp backreferences (<code>$N</code> and
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>%N</code>) which will be expanded. You can use this
06ba4a61654b3763ad65f52283832ebf058fdf1cslive flag more than once, to set more than one variable. The
06ba4a61654b3763ad65f52283832ebf058fdf1cslive variables can later be dereferenced in many situations, most commonly
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem from within XSSI (via <code>&lt;!--#echo
06ba4a61654b3763ad65f52283832ebf058fdf1cslive var="VAR"--&gt;</code>) or CGI (<code>$ENV{'VAR'}</code>).
06ba4a61654b3763ad65f52283832ebf058fdf1cslive You can also dereference the variable in a later RewriteCond pattern, using
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>%{ENV:VAR}</code>. Use this to strip
06ba4a61654b3763ad65f52283832ebf058fdf1cslive information from URLs, while maintaining a record of that information.</dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dt>'<code>forbidden|F</code>' (force URL
06ba4a61654b3763ad65f52283832ebf058fdf1cslive to be forbidden)</dt><dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive This forces the current URL to be forbidden - it immediately
96147932f199be4ad038778e702c13a2f79051c0slive sends back a HTTP response of 403 (FORBIDDEN).
81785f72c9d133aef57ad6b02f248345d90239aapoirier Use this flag in conjunction with
5ae30adbe59946de742ab0cd6be3b7457471a698takashi appropriate RewriteConds to conditionally block some
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem URLs.</dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dt>'<code>gone|G</code>' (force URL to be
06ba4a61654b3763ad65f52283832ebf058fdf1cslive gone)</dt><dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive This forces the current URL to be gone - it
06ba4a61654b3763ad65f52283832ebf058fdf1cslive immediately sends back a HTTP response of 410 (GONE). Use
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem this flag to mark pages which no longer exist as gone.</dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <dt>
81785f72c9d133aef57ad6b02f248345d90239aapoirier '<code>handler|H</code>=<em>Content-handler</em>'
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem (force Content handler)</dt><dd>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Force the Content-handler of the target file to be
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>Content-handler</em>. For instance, this can be used to
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem simulate the <code class="module"><a href="/mod/mod_alias.html">mod_alias</a></code> directive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code class="directive"><a href="/mod/mod_alias.html#scriptalias">ScriptAlias</a></code>,
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem which internally forces all files
06ba4a61654b3763ad65f52283832ebf058fdf1cslive inside the mapped directory to have a handler of
96147932f199be4ad038778e702c13a2f79051c0slive ``<code>cgi-script</code>''.<br />
96147932f199be4ad038778e702c13a2f79051c0slive If used in per-directory context, there must not be a substitution
96147932f199be4ad038778e702c13a2f79051c0slive which changes the path. Use this flag in per-directory context only
96147932f199be4ad038778e702c13a2f79051c0slive with <code>-</code> (dash) as the substitution, otherwise the request
96147932f199be4ad038778e702c13a2f79051c0slive will fail.</dd>
96147932f199be4ad038778e702c13a2f79051c0slive
96147932f199be4ad038778e702c13a2f79051c0slive <dt>'<code>last|L</code>'
96147932f199be4ad038778e702c13a2f79051c0slive (last rule)</dt><dd> Stop the rewriting process
81785f72c9d133aef57ad6b02f248345d90239aapoirier here and don't apply any more rewrite rules. This corresponds
96147932f199be4ad038778e702c13a2f79051c0slive to the Perl <code>last</code> command or the
70373b9ee042e7b3be82eee14b17f510fffdacc9slive <code>break</code> command in C. Use this flag to prevent the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive currently rewritten URL from being rewritten further by
ff21ab9f1cc3037fe58a2029432834581594b6c4pctony following rules. Remember, however, that if the
81785f72c9d133aef57ad6b02f248345d90239aapoirier <code class="directive">RewriteRule</code> generates an internal
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem redirect (which frequently occurs when rewriting in a
06ba4a61654b3763ad65f52283832ebf058fdf1cslive per-directory context), this will reinject the request and
81785f72c9d133aef57ad6b02f248345d90239aapoirier will cause processing to be repeated starting from the first
96147932f199be4ad038778e702c13a2f79051c0slive <code class="directive">RewriteRule</code>.</dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
8a571abb6573d916da05fc8b9f04fd944ad45803slive <dt>'<code>next|N</code>'
8a7ed8b6e3f5b266680dba1c890d1b9c6c0426efnoodl (next round)</dt><dd>
8a7ed8b6e3f5b266680dba1c890d1b9c6c0426efnoodl Re-run the rewriting process (starting again with the
8a7ed8b6e3f5b266680dba1c890d1b9c6c0426efnoodl first rewriting rule). This time, the URL to match is no longer
8a7ed8b6e3f5b266680dba1c890d1b9c6c0426efnoodl the original URL, but rather the URL returned by the last rewriting rule.
0a69d9bb491d9810892a9949c01403a1de3c7ac2nd This corresponds to the Perl <code>next</code> command or
a4d04b8c74044c58bd4182028a1408d936c95951covener the <code>continue</code> command in C. Use
a4d04b8c74044c58bd4182028a1408d936c95951covener this flag to restart the rewriting process -
a4d04b8c74044c58bd4182028a1408d936c95951covener to immediately go to the top of the loop.
0a69d9bb491d9810892a9949c01403a1de3c7ac2nd <strong>Be careful not to create an infinite
0a69d9bb491d9810892a9949c01403a1de3c7ac2nd loop!</strong></dd>
0a69d9bb491d9810892a9949c01403a1de3c7ac2nd
0a69d9bb491d9810892a9949c01403a1de3c7ac2nd <dt>'<code>nocase|NC</code>'
0a69d9bb491d9810892a9949c01403a1de3c7ac2nd (no case)</dt><dd>
8a7ed8b6e3f5b266680dba1c890d1b9c6c0426efnoodl This makes the <em>Pattern</em> case-insensitive,
8a7ed8b6e3f5b266680dba1c890d1b9c6c0426efnoodl ignoring difference between 'A-Z' and
8a7ed8b6e3f5b266680dba1c890d1b9c6c0426efnoodl 'a-z' when <em>Pattern</em> is matched against the current
8a7ed8b6e3f5b266680dba1c890d1b9c6c0426efnoodl URL.</dd>
8a571abb6573d916da05fc8b9f04fd944ad45803slive
8a571abb6573d916da05fc8b9f04fd944ad45803slive <dt>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen '<code>noescape|NE</code>'
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen (no URI escaping of
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem output)</dt><dd>
81785f72c9d133aef57ad6b02f248345d90239aapoirier This flag prevents mod_rewrite from applying the usual URI
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen escaping rules to the result of a rewrite. Ordinarily,
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen special characters (such as '%', '$', ';', and so on)
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem will be escaped into their hexcode equivalents ('%25',
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem '%24', and '%3B', respectively); this flag prevents this
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen from happening. This allows percent symbols to appear in
8a571abb6573d916da05fc8b9f04fd944ad45803slive the output, as in
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen<div class="example"><p><code>
623eebe956d9c2d6d073ed3eae855b56030b40e9noodl RewriteRule ^/foo/(.*) /bar?arg=P1\%3d$1 [R,NE]
8a571abb6573d916da05fc8b9f04fd944ad45803slive</code></p></div>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem which would turn '<code>/foo/zed</code>' into a safe
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen request for '<code>/bar?arg=P1=zed</code>'.
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen </dd>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
401df5e4388bdd659aa90db2e36a4a9a7af79524rpluem <dt>
401df5e4388bdd659aa90db2e36a4a9a7af79524rpluem '<code>nosubreq|NS</code>'
623eebe956d9c2d6d073ed3eae855b56030b40e9noodl (not for internal
401df5e4388bdd659aa90db2e36a4a9a7af79524rpluem sub-requests)</dt><dd>
401df5e4388bdd659aa90db2e36a4a9a7af79524rpluem <p>This flag forces the rewriting engine to skip a
623eebe956d9c2d6d073ed3eae855b56030b40e9noodl rewriting rule if the current request is an internal
623eebe956d9c2d6d073ed3eae855b56030b40e9noodl sub-request. For instance, sub-requests occur internally
06ba4a61654b3763ad65f52283832ebf058fdf1cslive in Apache when <code class="module"><a href="/mod/mod_dir.html">mod_dir</a></code> tries to find out
1464434c2c104e0ba224644c42552330f5158537covener information about possible directory default files
1464434c2c104e0ba224644c42552330f5158537covener (<code>index.xxx</code> files). On sub-requests it is not
81785f72c9d133aef57ad6b02f248345d90239aapoirier always useful, and can even cause errors, if
1464434c2c104e0ba224644c42552330f5158537covener the complete set of rules are applied. Use this flag to
81785f72c9d133aef57ad6b02f248345d90239aapoirier exclude some rules.</p>
81785f72c9d133aef57ad6b02f248345d90239aapoirier <p>To decide whether or not to use this rule: if you
1464434c2c104e0ba224644c42552330f5158537covener prefix URLs with CGI-scripts, to force them to be
1464434c2c104e0ba224644c42552330f5158537covener processed by the CGI-script, it's likely that you
907c2e66b6ee3e080cb51db0573b19983efce358covener will run into problems (or significant overhead) on
1464434c2c104e0ba224644c42552330f5158537covener sub-requests. In these cases, use this flag.</p>
1464434c2c104e0ba224644c42552330f5158537covener </dd>
81785f72c9d133aef57ad6b02f248345d90239aapoirier
81785f72c9d133aef57ad6b02f248345d90239aapoirier <dt>
1464434c2c104e0ba224644c42552330f5158537covener '<code>proxy|P</code>' (force
1464434c2c104e0ba224644c42552330f5158537covener proxy)</dt><dd>
1464434c2c104e0ba224644c42552330f5158537covener This flag forces the substitution part to be internally
81785f72c9d133aef57ad6b02f248345d90239aapoirier sent as a proxy request and immediately (rewrite
1464434c2c104e0ba224644c42552330f5158537covener processing stops here) put through the <a href="mod_proxy.html">proxy module</a>. You must make
1464434c2c104e0ba224644c42552330f5158537covener sure that the substitution string is a valid URI
1464434c2c104e0ba224644c42552330f5158537covener (typically starting with
81785f72c9d133aef57ad6b02f248345d90239aapoirier <code>http://</code><em>hostname</em>) which can be
81785f72c9d133aef57ad6b02f248345d90239aapoirier handled by the Apache proxy module. If not, you will get an
81785f72c9d133aef57ad6b02f248345d90239aapoirier error from the proxy module. Use this flag to achieve a
1464434c2c104e0ba224644c42552330f5158537covener more powerful implementation of the <a href="mod_proxy.html#proxypass">ProxyPass</a> directive,
81785f72c9d133aef57ad6b02f248345d90239aapoirier to map remote content into the namespace of the local
81785f72c9d133aef57ad6b02f248345d90239aapoirier server.
1464434c2c104e0ba224644c42552330f5158537covener
1464434c2c104e0ba224644c42552330f5158537covener <p>Note: <code class="module"><a href="/mod/mod_proxy.html">mod_proxy</a></code> must be enabled in order
8a571abb6573d916da05fc8b9f04fd944ad45803slive to use this flag.</p>
8a571abb6573d916da05fc8b9f04fd944ad45803slive </dd>
8a571abb6573d916da05fc8b9f04fd944ad45803slive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <dt>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen '<code>passthrough|PT</code>'
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem (pass through to next
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem handler)</dt><dd>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem This flag forces the rewrite engine to set the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>uri</code> field of the internal
5ae30adbe59946de742ab0cd6be3b7457471a698takashi <code>request_rec</code> structure to the value of the
81785f72c9d133aef57ad6b02f248345d90239aapoirier <code>filename</code> field. This flag is just a hack to
5ae30adbe59946de742ab0cd6be3b7457471a698takashi enable post-processing of the output of
81785f72c9d133aef57ad6b02f248345d90239aapoirier <code>RewriteRule</code> directives, using
8a571abb6573d916da05fc8b9f04fd944ad45803slive <code>Alias</code>, <code>ScriptAlias</code>,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>Redirect</code>, and other directives from
8a571abb6573d916da05fc8b9f04fd944ad45803slive various URI-to-filename translators. For example, to rewrite
8a571abb6573d916da05fc8b9f04fd944ad45803slive <code>/abc</code> to <code>/def</code> using
81785f72c9d133aef57ad6b02f248345d90239aapoirier <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code>, and then
81785f72c9d133aef57ad6b02f248345d90239aapoirier <code>/def</code> to <code>/ghi</code> using
5ae30adbe59946de742ab0cd6be3b7457471a698takashi <code class="module"><a href="/mod/mod_alias.html">mod_alias</a></code>:
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<div class="example"><p><code>
8a571abb6573d916da05fc8b9f04fd944ad45803slive RewriteRule ^/abc(.*) /def$1 [PT]<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive Alias /def /ghi
8a571abb6573d916da05fc8b9f04fd944ad45803slive</code></p></div>
8a571abb6573d916da05fc8b9f04fd944ad45803slive If you omit the <code>PT</code> flag,
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> will rewrite
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>uri=/abc/...</code> to
8a571abb6573d916da05fc8b9f04fd944ad45803slive <code>filename=/def/...</code> as a full API-compliant
06ba4a61654b3763ad65f52283832ebf058fdf1cslive URI-to-filename translator should do. Then
8a571abb6573d916da05fc8b9f04fd944ad45803slive <code>mod_alias</code> will try to do a
8a571abb6573d916da05fc8b9f04fd944ad45803slive URI-to-filename transition, which will fail.
8a571abb6573d916da05fc8b9f04fd944ad45803slive
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen <p>Note: <strong>You must use this flag if you want to
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen mix directives from different modules which allow
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem URL-to-filename translators</strong>. The typical example
81785f72c9d133aef57ad6b02f248345d90239aapoirier is the use of <code class="module"><a href="/mod/mod_alias.html">mod_alias</a></code> and
5ae30adbe59946de742ab0cd6be3b7457471a698takashi <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code>.</p>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen
a4d04b8c74044c58bd4182028a1408d936c95951covener <p>The <code>PT</code> flag implies the <code>L</code> flag:
a4d04b8c74044c58bd4182028a1408d936c95951covener rewriting will be stopped in order to pass the request to
a4d04b8c74044c58bd4182028a1408d936c95951covener the next phase of processing.</p>
a4d04b8c74044c58bd4182028a1408d936c95951covener </dd>
a4d04b8c74044c58bd4182028a1408d936c95951covener
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dt>'<code>qsappend|QSA</code>'
8a571abb6573d916da05fc8b9f04fd944ad45803slive (query string
8a571abb6573d916da05fc8b9f04fd944ad45803slive append)</dt><dd>
8ed0917f332087770872e032b248b2e1e689df3bslive This flag forces the rewrite engine to append the query
8ed0917f332087770872e032b248b2e1e689df3bslive string part of the substitution string to the existing query string,
8ed0917f332087770872e032b248b2e1e689df3bslive instead of replacing it. Use this when you want to add more
8ed0917f332087770872e032b248b2e1e689df3bslive data to the query string via a rewrite rule. This rule has no net effect
8ed0917f332087770872e032b248b2e1e689df3bslive unless your substitution explicitly provides a new query string.</dd>
8ed0917f332087770872e032b248b2e1e689df3bslive
8ed0917f332087770872e032b248b2e1e689df3bslive <dt>'<code>redirect|R</code>
8ed0917f332087770872e032b248b2e1e689df3bslive [=<em>code</em>]' (force <a id="redirect" name="redirect">redirect</a>)</dt><dd>
8ed0917f332087770872e032b248b2e1e689df3bslive <p>Prefix <em>Substitution</em> with
8a571abb6573d916da05fc8b9f04fd944ad45803slive <code>http://thishost[:thisport]/</code> (which makes the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive new URL a URI) to force a external redirection. If no
8a571abb6573d916da05fc8b9f04fd944ad45803slive <em>code</em> is given, a HTTP response of 302 (MOVED
8a571abb6573d916da05fc8b9f04fd944ad45803slive TEMPORARILY) will be returned. If you want to use other
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem response codes, simply specify the appropriate number or use
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem one of the following symbolic names: <code>temp</code>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem (default), <code>permanent</code>,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>seeother</code>. Use this for rules to canonicalize
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem the URL and return it to the client - to translate
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem ``<code>/~</code>'' into ``<code>/u/</code>'', or to always
8a571abb6573d916da05fc8b9f04fd944ad45803slive append a slash to <code>/u/</code><em>user</em>, etc.<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <strong>Note:</strong> When you use this flag, make sure
8a571abb6573d916da05fc8b9f04fd944ad45803slive that the substitution field is a valid URL! Otherwise, you
06ba4a61654b3763ad65f52283832ebf058fdf1cslive will be redirecting to an invalid location. Remember that
8a571abb6573d916da05fc8b9f04fd944ad45803slive this flag on its own will only prepend
8a571abb6573d916da05fc8b9f04fd944ad45803slive <code>http://thishost[:thisport]/</code> to the URL, and
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem rewriting will continue. Usually, you will want to stop
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem rewriting at this point, and redirect immediately. To stop
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen rewriting, you should add the 'L' flag.</p>
8a571abb6573d916da05fc8b9f04fd944ad45803slive <p>While this is typically used for redirects, any valid status
06ba4a61654b3763ad65f52283832ebf058fdf1cslive code can be given here. If the status code is outside the redirect
8a571abb6573d916da05fc8b9f04fd944ad45803slive range (300-399), then the <em>Substitution</em> string is dropped
8a571abb6573d916da05fc8b9f04fd944ad45803slive and rewriting is stopped as if the <code>L</code> flag was
8a571abb6573d916da05fc8b9f04fd944ad45803slive used.</p>
8a571abb6573d916da05fc8b9f04fd944ad45803slive </dd>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen <dt>'<code>skip|S</code>=<em>num</em>'
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen (skip next rule(s))</dt><dd>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen This flag forces the rewriting engine to skip the next
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen <em>num</em> rules in sequence, if the current rule
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem matches. Use this to make pseudo if-then-else constructs:
81785f72c9d133aef57ad6b02f248345d90239aapoirier The last rule of the then-clause becomes
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen <code>skip=N</code>, where N is the number of rules in the
a4d04b8c74044c58bd4182028a1408d936c95951covener else-clause. (This is <strong>not</strong> the same as the
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen 'chain|C' flag!)</dd>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen
81785f72c9d133aef57ad6b02f248345d90239aapoirier <dt>
8a571abb6573d916da05fc8b9f04fd944ad45803slive '<code>type|T</code>=<em>MIME-type</em>'
06ba4a61654b3763ad65f52283832ebf058fdf1cslive (force MIME type)</dt><dd>
8a571abb6573d916da05fc8b9f04fd944ad45803slive Force the <a class="glossarylink" href="/glossary.html#mime-type" title="see glossary">MIME-type</a> of the target file to be
8a571abb6573d916da05fc8b9f04fd944ad45803slive <em>MIME-type</em>. This can be used to
8a571abb6573d916da05fc8b9f04fd944ad45803slive set up the content-type based on some conditions.
8a571abb6573d916da05fc8b9f04fd944ad45803slive If used in per-directory context, use only <code>-</code> (dash)
8a571abb6573d916da05fc8b9f04fd944ad45803slive as the substitution, otherwise the MIME-type set with this flag
06ba4a61654b3763ad65f52283832ebf058fdf1cslive is lost due to an internal re-processing.</dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </dl>
a4d04b8c74044c58bd4182028a1408d936c95951covener
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<div class="note"><h3>Home directory expansion</h3>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<p> When the substitution string begins with a string
06ba4a61654b3763ad65f52283832ebf058fdf1csliveresembling "/~user" (via explicit text or backreferences), mod_rewrite performs
8a571abb6573d916da05fc8b9f04fd944ad45803slivehome directory expansion independent of the presence or configuration
8a571abb6573d916da05fc8b9f04fd944ad45803sliveof <code class="module"><a href="/mod/mod_userdir.html">mod_userdir</a></code>.</p>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
81785f72c9d133aef57ad6b02f248345d90239aapoirier<p> This expansion does not occur when the <em>PT</em>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluemflag is used on the <code class="directive"><a href="#rewriterule">RewriteRule</a></code>
8a571abb6573d916da05fc8b9f04fd944ad45803slivedirective.</p>
8a571abb6573d916da05fc8b9f04fd944ad45803slive</div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
8a571abb6573d916da05fc8b9f04fd944ad45803slive<div class="note"><h3>Per-directory Rewrites</h3>
8a571abb6573d916da05fc8b9f04fd944ad45803slive
8a571abb6573d916da05fc8b9f04fd944ad45803slive<p>The rewrite engine may be used in <a href="/howto/htaccess.html">.htaccess</a> files. To enable the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluemrewrite engine for these files you need to set
81785f72c9d133aef57ad6b02f248345d90239aapoirier"<code>RewriteEngine On</code>" <strong>and</strong>
5ae30adbe59946de742ab0cd6be3b7457471a698takashi"<code>Options FollowSymLinks</code>" must be enabled. If your
173a6aaf8f8d2c818ab71d3781400e521051a565rbowenadministrator has disabled override of <code>FollowSymLinks</code> for
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluema user's directory, then you cannot use the rewrite engine. This
173a6aaf8f8d2c818ab71d3781400e521051a565rbowenrestriction is required for security reasons.</p>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen<p>When using the rewrite engine in <code>.htaccess</code> files the
173a6aaf8f8d2c818ab71d3781400e521051a565rbowenper-directory prefix (which always is the same for a specific
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluemdirectory) is automatically <em>removed</em> for the pattern matching
81785f72c9d133aef57ad6b02f248345d90239aapoirierand automatically <em>added</em> after the substitution has been
06ba4a61654b3763ad65f52283832ebf058fdf1cslivedone. This feature is essential for many sorts of rewriting; without
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluemthis, you would always have to match the parent directory, which is
9b82bd7c7f2083318e7856831dede324534308bcrbowennot always possible. There is one exception: If a substitution string
8a571abb6573d916da05fc8b9f04fd944ad45803slivestarts with <code>http://</code>, then the directory prefix will
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<strong>not</strong> be added, and an external redirect (or proxy
8a571abb6573d916da05fc8b9f04fd944ad45803slivethroughput, if using flag <strong>P</strong>) is forced. See the
8a571abb6573d916da05fc8b9f04fd944ad45803slive<code class="directive"><a href="#rewritebase">RewriteBase</a></code> directive for
8a571abb6573d916da05fc8b9f04fd944ad45803slivemore information.</p>
8a571abb6573d916da05fc8b9f04fd944ad45803slive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<p>The rewrite engine may also be used in <code class="directive"><a href="/mod/core.html#directory">&lt;Directory&gt;</a></code> sections with the same
06ba4a61654b3763ad65f52283832ebf058fdf1csliveprefix-matching rules as would be applied to <code>.htaccess</code>
06ba4a61654b3763ad65f52283832ebf058fdf1cslivefiles. It is usually simpler, however, to avoid the prefix substitution
06ba4a61654b3763ad65f52283832ebf058fdf1cslivecomplication by putting the rewrite rules in the main server or
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluemvirtual host context, rather than in a <code class="directive"><a href="/mod/core.html#directory">&lt;Directory&gt;</a></code> section.</p>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<p>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
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluemshould never be necessary and is unsupported.</p>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem</div>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p>Here are all possible substitution combinations and their
81785f72c9d133aef57ad6b02f248345d90239aapoirier meanings:</p>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
97a9a944b5887e91042b019776c41d5dd74557aferikabele <p><strong>Inside per-server configuration
06ba4a61654b3763ad65f52283832ebf058fdf1cslive (<code>httpd.conf</code>)<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele for request ``<code>GET
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem /somepath/pathinfo</code>'':</strong><br />
81785f72c9d133aef57ad6b02f248345d90239aapoirier </p>
5ae30adbe59946de742ab0cd6be3b7457471a698takashi
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<div class="note"><pre>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<strong>Given Rule</strong> <strong>Resulting Substitution</strong>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem---------------------------------------------- ----------------------------------
81785f72c9d133aef57ad6b02f248345d90239aapoirier^/somepath(.*) otherpath$1 invalid, not supported
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem^/somepath(.*) otherpath$1 [R] invalid, not supported
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive^/somepath(.*) otherpath$1 [P] invalid, not supported
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem---------------------------------------------- ----------------------------------
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem^/somepath(.*) /otherpath$1 /otherpath/pathinfo
b5407b0669a6a7175c84859e727d133399e4fa51slive
b5407b0669a6a7175c84859e727d133399e4fa51slive^/somepath(.*) /otherpath$1 [R] http://thishost/otherpath/pathinfo
b5407b0669a6a7175c84859e727d133399e4fa51slive via external redirection
b5407b0669a6a7175c84859e727d133399e4fa51slive
8a571abb6573d916da05fc8b9f04fd944ad45803slive^/somepath(.*) /otherpath$1 [P] doesn't make sense, not supported
06ba4a61654b3763ad65f52283832ebf058fdf1cslive---------------------------------------------- ----------------------------------
8a571abb6573d916da05fc8b9f04fd944ad45803slive^/somepath(.*) http://thishost/otherpath$1 /otherpath/pathinfo
8a571abb6573d916da05fc8b9f04fd944ad45803slive
8a571abb6573d916da05fc8b9f04fd944ad45803slive^/somepath(.*) http://thishost/otherpath$1 [R] http://thishost/otherpath/pathinfo
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem via external redirection
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen^/somepath(.*) http://thishost/otherpath$1 [P] doesn't make sense, not supported
8a571abb6573d916da05fc8b9f04fd944ad45803slive---------------------------------------------- ----------------------------------
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen^/somepath(.*) http://otherhost/otherpath$1 http://otherhost/otherpath/pathinfo
8a571abb6573d916da05fc8b9f04fd944ad45803slive via external redirection
8a571abb6573d916da05fc8b9f04fd944ad45803slive
8a571abb6573d916da05fc8b9f04fd944ad45803slive^/somepath(.*) http://otherhost/otherpath$1 [R] http://otherhost/otherpath/pathinfo
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen via external redirection
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen (the [R] flag is redundant)
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
8a571abb6573d916da05fc8b9f04fd944ad45803slive^/somepath(.*) http://otherhost/otherpath$1 [P] http://otherhost/otherpath/pathinfo
8a571abb6573d916da05fc8b9f04fd944ad45803slive via internal proxy
8a571abb6573d916da05fc8b9f04fd944ad45803slive</pre></div>
8a571abb6573d916da05fc8b9f04fd944ad45803slive
8a571abb6573d916da05fc8b9f04fd944ad45803slive <p><strong>Inside per-directory configuration for
8a571abb6573d916da05fc8b9f04fd944ad45803slive <code>/somepath</code><br />
8a571abb6573d916da05fc8b9f04fd944ad45803slive (<code>/physical/path/to/somepath/.htacccess</code>, with
8a571abb6573d916da05fc8b9f04fd944ad45803slive <code>RewriteBase /somepath</code>)<br />
8a571abb6573d916da05fc8b9f04fd944ad45803slive for request ``<code>GET
8a571abb6573d916da05fc8b9f04fd944ad45803slive /somepath/localpath/pathinfo</code>'':</strong><br />
8a571abb6573d916da05fc8b9f04fd944ad45803slive </p>
8a571abb6573d916da05fc8b9f04fd944ad45803slive
8a571abb6573d916da05fc8b9f04fd944ad45803slive<div class="note"><pre>
8a571abb6573d916da05fc8b9f04fd944ad45803slive<strong>Given Rule</strong> <strong>Resulting Substitution</strong>
8a571abb6573d916da05fc8b9f04fd944ad45803slive---------------------------------------------- ----------------------------------
8a571abb6573d916da05fc8b9f04fd944ad45803slive^localpath(.*) otherpath$1 /somepath/otherpath/pathinfo
758cbf6f938a9e5b39422509d1e39b7078c1a1dcslive
758cbf6f938a9e5b39422509d1e39b7078c1a1dcslive^localpath(.*) otherpath$1 [R] http://thishost/somepath/otherpath/pathinfo
758cbf6f938a9e5b39422509d1e39b7078c1a1dcslive via external redirection
758cbf6f938a9e5b39422509d1e39b7078c1a1dcslive
758cbf6f938a9e5b39422509d1e39b7078c1a1dcslive^localpath(.*) otherpath$1 [P] doesn't make sense, not supported
8a571abb6573d916da05fc8b9f04fd944ad45803slive---------------------------------------------- ----------------------------------
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen^localpath(.*) /otherpath$1 /otherpath/pathinfo
8a571abb6573d916da05fc8b9f04fd944ad45803slive
8a571abb6573d916da05fc8b9f04fd944ad45803slive^localpath(.*) /otherpath$1 [R] http://thishost/otherpath/pathinfo
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem via external redirection
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive^localpath(.*) /otherpath$1 [P] doesn't make sense, not supported
06ba4a61654b3763ad65f52283832ebf058fdf1cslive---------------------------------------------- ----------------------------------
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem^localpath(.*) http://thishost/otherpath$1 /otherpath/pathinfo
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
8a571abb6573d916da05fc8b9f04fd944ad45803slive^localpath(.*) http://thishost/otherpath$1 [R] http://thishost/otherpath/pathinfo
06ba4a61654b3763ad65f52283832ebf058fdf1cslive via external redirection
8a571abb6573d916da05fc8b9f04fd944ad45803slive
8a571abb6573d916da05fc8b9f04fd944ad45803slive^localpath(.*) http://thishost/otherpath$1 [P] doesn't make sense, not supported
8a571abb6573d916da05fc8b9f04fd944ad45803slive---------------------------------------------- ----------------------------------
20189240503ef2c8f5dc6e2248b57faab4b23b5and^localpath(.*) http://otherhost/otherpath$1 http://otherhost/otherpath/pathinfo
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem via external redirection
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
a4d04b8c74044c58bd4182028a1408d936c95951covener^localpath(.*) http://otherhost/otherpath$1 [R] http://otherhost/otherpath/pathinfo
a4d04b8c74044c58bd4182028a1408d936c95951covener via external redirection
a4d04b8c74044c58bd4182028a1408d936c95951covener (the [R] flag is redundant)
8a571abb6573d916da05fc8b9f04fd944ad45803slive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive^localpath(.*) http://otherhost/otherpath$1 [P] http://otherhost/otherpath/pathinfo
ff21ab9f1cc3037fe58a2029432834581594b6c4pctony via internal proxy
de68ca33425122cf4a880859013e08e84f8143a5covener</pre></div>
de68ca33425122cf4a880859013e08e84f8143a5covener
de68ca33425122cf4a880859013e08e84f8143a5covener</div>
81785f72c9d133aef57ad6b02f248345d90239aapoirier</div>
4e6d765a1b53690664877065e6b6c741c1b96937covener<div class="bottomlang">
de68ca33425122cf4a880859013e08e84f8143a5covener<p><span>Available Languages: </span><a href="/en/mod/mod_rewrite.html" title="English">&nbsp;en&nbsp;</a> |
de68ca33425122cf4a880859013e08e84f8143a5covener<a href="/fr/mod/mod_rewrite.html" hreflang="fr" rel="alternate" title="Fran�ais">&nbsp;fr&nbsp;</a></p>
de68ca33425122cf4a880859013e08e84f8143a5covener</div><div id="footer">
de68ca33425122cf4a880859013e08e84f8143a5covener<p class="apache">Copyright 2009 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>
de68ca33425122cf4a880859013e08e84f8143a5covener<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="/faq/">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p></div>
de68ca33425122cf4a880859013e08e84f8143a5covener</body></html>