mod_rewrite.html.en revision 4eafd186275d2df6e74aaa778a57b24a6c725e49
fb18194cd0e59b737cc179eb2354a2dcd16087d4trawick<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
fb18194cd0e59b737cc179eb2354a2dcd16087d4trawick<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
fb18194cd0e59b737cc179eb2354a2dcd16087d4trawick XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
fb18194cd0e59b737cc179eb2354a2dcd16087d4trawick This file is generated from xml source: DO NOT EDIT
fb18194cd0e59b737cc179eb2354a2dcd16087d4trawick XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
fb18194cd0e59b737cc179eb2354a2dcd16087d4trawick<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
fb18194cd0e59b737cc179eb2354a2dcd16087d4trawick<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
fb18194cd0e59b737cc179eb2354a2dcd16087d4trawick<link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="/style/css/prettify.css" />
fb18194cd0e59b737cc179eb2354a2dcd16087d4trawick<script src="/style/scripts/prettify.js" type="text/javascript">
fb18194cd0e59b737cc179eb2354a2dcd16087d4trawick<link href="/images/favicon.ico" rel="shortcut icon" /></head>
fb18194cd0e59b737cc179eb2354a2dcd16087d4trawick<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick<div class="up"><a href="./"><img title="<-" alt="<-" src="/images/left.gif" /></a></div>
61a4b32b1032d530e84e1131cb803f803acf7461trawick<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.5</a> > <a href="./">Modules</a></div>
182d9b96e04124d14c9f539109fb4e8cbd360d36trawick<div id="preamble"><h1>Apache Module mod_rewrite</h1>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick<p><span>Available Languages: </span><a href="/en/mod/mod_rewrite.html" title="English"> en </a> |
88c0d6d1cfdecfa8c2b6d7ae2482f06755cd7887trawick<a href="/fr/mod/mod_rewrite.html" hreflang="fr" rel="alternate" title="Fran�ais"> fr </a></p>
f6ba728fd666800e11b36452f7ad76ec5fcff653trawick<table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Provides a rule-based rewriting engine to rewrite requested
f6ba728fd666800e11b36452f7ad76ec5fcff653trawick<tr><th><a href="module-dict.html#Status">Status:</a></th><td>Extension</td></tr>
f6ba728fd666800e11b36452f7ad76ec5fcff653trawick<tr><th><a href="module-dict.html#ModuleIdentifier">Module�Identifier:</a></th><td>rewrite_module</td></tr>
f6ba728fd666800e11b36452f7ad76ec5fcff653trawick<tr><th><a href="module-dict.html#SourceFile">Source�File:</a></th><td>mod_rewrite.c</td></tr></table>
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick <p>The <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> module uses a rule-based rewriting
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick engine, based on a PCRE regular-expression parser, to rewrite requested URLs on
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick the fly. By default, <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> maps a URL to a filesystem
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick path. However, it can also be used to redirect one URL to another URL, or
d66e2366f1cceb0e2b107020fe61e36d090b6d9ctrawick to invoke an internal proxy fetch.</p>
d66e2366f1cceb0e2b107020fe61e36d090b6d9ctrawick <p><code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> provides a flexible and powerful way to
d66e2366f1cceb0e2b107020fe61e36d090b6d9ctrawick manipulate URLs using an unlimited number of rules. Each rule can have an
d66e2366f1cceb0e2b107020fe61e36d090b6d9ctrawick unlimited number of attached rule conditions, to allow you to rewrite URL
d66e2366f1cceb0e2b107020fe61e36d090b6d9ctrawick based on server variables, environment variables, HTTP headers, or time
d66e2366f1cceb0e2b107020fe61e36d090b6d9ctrawick stamps.</p>
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick <p><code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> operates on the full URL path, including the
d66e2366f1cceb0e2b107020fe61e36d090b6d9ctrawick path-info section. A rewrite rule can be invoked in
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick <code>httpd.conf</code> or in <code>.htaccess</code>. The path generated
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick by a rewrite rule can include a query string, or can lead to internal
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick sub-processing, external request redirection, or internal proxy
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick throughput.</p>
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick <p>Further details, discussion, and examples, are provided in the
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick <a href="/rewrite/">detailed mod_rewrite documentation</a>.</p>
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick<div id="quickview"><h3 class="directives">Directives</h3>
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick<li><img alt="" src="/images/down.gif" /> <a href="#rewritebase">RewriteBase</a></li>
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick<li><img alt="" src="/images/down.gif" /> <a href="#rewritecond">RewriteCond</a></li>
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick<li><img alt="" src="/images/down.gif" /> <a href="#rewriteengine">RewriteEngine</a></li>
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick<li><img alt="" src="/images/down.gif" /> <a href="#rewritemap">RewriteMap</a></li>
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick<li><img alt="" src="/images/down.gif" /> <a href="#rewriteoptions">RewriteOptions</a></li>
182d9b96e04124d14c9f539109fb4e8cbd360d36trawick<li><img alt="" src="/images/down.gif" /> <a href="#rewriterule">RewriteRule</a></li>
798cfee8074b529042079c77eee6962a723350detrawick<li><img alt="" src="/images/down.gif" /> <a href="#logging">Logging</a></li>
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick</ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
bbd9d609b3e1f45b4a5beda3ef5e8a589b3657b4trawick <p><code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> offers detailed logging of its actions
bbd9d609b3e1f45b4a5beda3ef5e8a589b3657b4trawick at the <code>trace1</code> to <code>trace8</code> log levels. The
bbd9d609b3e1f45b4a5beda3ef5e8a589b3657b4trawick log level can be set specifically for <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code>
798cfee8074b529042079c77eee6962a723350detrawick using the <code class="directive"><a href="/mod/core.html#loglevel">LogLevel</a></code> directive: Up to
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick level <code>debug</code>, no actions are logged, while <code>trace8</code>
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick means that practically all actions are logged.</p>
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick Using a high trace log level for <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code>
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick will slow down your Apache HTTP Server dramatically! Use a log
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick level higher than <code>trace2</code> only for debugging!
e5819d621124ccc8ee3b7f1854c2d55ffaf91d32trawick <div class="example"><h3>Example</h3><pre class="prettyprint lang-config">
e5819d621124ccc8ee3b7f1854c2d55ffaf91d32trawick LogLevel alert rewrite:trace3
e5819d621124ccc8ee3b7f1854c2d55ffaf91d32trawick <p>Those familiar with earlier versions of
e5819d621124ccc8ee3b7f1854c2d55ffaf91d32trawick <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> will no doubt be looking for the
e5819d621124ccc8ee3b7f1854c2d55ffaf91d32trawick <code>RewriteLog</code> and <code>RewriteLogLevel</code>
e5819d621124ccc8ee3b7f1854c2d55ffaf91d32trawick directives. This functionality has been completely replaced by the
e5819d621124ccc8ee3b7f1854c2d55ffaf91d32trawick new per-module logging configuration mentioned above.
e5819d621124ccc8ee3b7f1854c2d55ffaf91d32trawick <p>To get just the <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code>-specific log
e5819d621124ccc8ee3b7f1854c2d55ffaf91d32trawick messages, pipe the log file through grep:</p>
e5819d621124ccc8ee3b7f1854c2d55ffaf91d32trawick tail -f error_log|fgrep '[rewrite:'
61a4b32b1032d530e84e1131cb803f803acf7461trawick<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
61a4b32b1032d530e84e1131cb803f803acf7461trawick<div class="directive-section"><h2><a name="RewriteBase" id="RewriteBase">RewriteBase</a> <a name="rewritebase" id="rewritebase">Directive</a></h2>
61a4b32b1032d530e84e1131cb803f803acf7461trawick<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets the base URL for per-directory rewrites</td></tr>
61a4b32b1032d530e84e1131cb803f803acf7461trawick<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteBase <em>URL-path</em></code></td></tr>
61a4b32b1032d530e84e1131cb803f803acf7461trawick<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>None</code></td></tr>
61a4b32b1032d530e84e1131cb803f803acf7461trawick<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>directory, .htaccess</td></tr>
61a4b32b1032d530e84e1131cb803f803acf7461trawick<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
61a4b32b1032d530e84e1131cb803f803acf7461trawick<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
61a4b32b1032d530e84e1131cb803f803acf7461trawick<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
61a4b32b1032d530e84e1131cb803f803acf7461trawick <p>The <code class="directive">RewriteBase</code> directive specifies the
61a4b32b1032d530e84e1131cb803f803acf7461trawick URL prefix to be used for per-directory (htaccess)
61a4b32b1032d530e84e1131cb803f803acf7461trawick <code class="directive">RewriteRule</code> directives that substitute a relative
61a4b32b1032d530e84e1131cb803f803acf7461trawick <p> This directive is <em>required</em> when you use a relative path
61a4b32b1032d530e84e1131cb803f803acf7461trawick in a substitution in per-directory (htaccess) context unless either
61a4b32b1032d530e84e1131cb803f803acf7461trawick of the following conditions are true:</p>
61a4b32b1032d530e84e1131cb803f803acf7461trawick <li> The original request, and the substitution, are underneath the
61a4b32b1032d530e84e1131cb803f803acf7461trawick <code class="directive"><a href="/mod/core.html#documentroot">DocumentRoot</a></code>
61a4b32b1032d530e84e1131cb803f803acf7461trawick (as opposed to reachable by other means, such as
61a4b32b1032d530e84e1131cb803f803acf7461trawick <code class="directive"><a href="/mod/mod_alias.html#alias">Alias</a></code>).</li>
61a4b32b1032d530e84e1131cb803f803acf7461trawick <li> The <em>filesystem</em> path to the directory containing the
61a4b32b1032d530e84e1131cb803f803acf7461trawick <code class="directive">RewriteRule</code>, suffixed by the relative
61a4b32b1032d530e84e1131cb803f803acf7461trawick substitution is also valid as a URL path on the server
61a4b32b1032d530e84e1131cb803f803acf7461trawick (this is rare).</li>
61a4b32b1032d530e84e1131cb803f803acf7461trawick<p> In the example below, <code class="directive">RewriteBase</code> is necessary
61a4b32b1032d530e84e1131cb803f803acf7461trawick to avoid rewriting to http://example.com/opt/myapp-1.2.3/welcome.html
61a4b32b1032d530e84e1131cb803f803acf7461trawick since the resource was not relative to the document root. This
61a4b32b1032d530e84e1131cb803f803acf7461trawick misconfiguration would normally cause the server to look for an "opt"
61a4b32b1032d530e84e1131cb803f803acf7461trawick directory under the document root.</p>
61a4b32b1032d530e84e1131cb803f803acf7461trawick RewriteEngine On
61a4b32b1032d530e84e1131cb803f803acf7461trawick RewriteBase /myapp/
61a4b32b1032d530e84e1131cb803f803acf7461trawick RewriteRule ^index\.html$ welcome.html
61a4b32b1032d530e84e1131cb803f803acf7461trawick</Directory>
61a4b32b1032d530e84e1131cb803f803acf7461trawick<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
61a4b32b1032d530e84e1131cb803f803acf7461trawick<div class="directive-section"><h2><a name="RewriteCond" id="RewriteCond">RewriteCond</a> <a name="rewritecond" id="rewritecond">Directive</a></h2>
61a4b32b1032d530e84e1131cb803f803acf7461trawick<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Defines a condition under which rewriting will take place
61a4b32b1032d530e84e1131cb803f803acf7461trawick<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code> RewriteCond
61a4b32b1032d530e84e1131cb803f803acf7461trawick <em>TestString</em> <em>CondPattern</em></code></td></tr>
61a4b32b1032d530e84e1131cb803f803acf7461trawick<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
61a4b32b1032d530e84e1131cb803f803acf7461trawick<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
61a4b32b1032d530e84e1131cb803f803acf7461trawick<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
61a4b32b1032d530e84e1131cb803f803acf7461trawick<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
61a4b32b1032d530e84e1131cb803f803acf7461trawick <p>The <code class="directive">RewriteCond</code> directive defines a
61a4b32b1032d530e84e1131cb803f803acf7461trawick rule condition. One or more <code class="directive">RewriteCond</code>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick can precede a <code class="directive"><a href="#rewriterule">RewriteRule</a></code>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick directive. The following rule is then only used if both
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick the current state of the URI matches its pattern, <strong>and</strong> if these conditions are met.</p>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <p><em>TestString</em> is a string which can contain the
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick following expanded constructs in addition to plain text:</p>
cf30286e95bd9b293bb4e3d5e4b89ed9d51d7a3ftrawick <strong>RewriteRule backreferences</strong>: These are
cf30286e95bd9b293bb4e3d5e4b89ed9d51d7a3ftrawick backreferences of the form <strong><code>$N</code></strong>
cf30286e95bd9b293bb4e3d5e4b89ed9d51d7a3ftrawick (0 <= N <= 9). $1 to $9 provide access to the grouped
cf30286e95bd9b293bb4e3d5e4b89ed9d51d7a3ftrawick parts (in parentheses) of the pattern, from the
cf30286e95bd9b293bb4e3d5e4b89ed9d51d7a3ftrawick <code>RewriteRule</code> which is subject to the current
cf30286e95bd9b293bb4e3d5e4b89ed9d51d7a3ftrawick set of <code>RewriteCond</code> conditions. $0 provides
cf30286e95bd9b293bb4e3d5e4b89ed9d51d7a3ftrawick access to the whole string matched by that pattern.
cf30286e95bd9b293bb4e3d5e4b89ed9d51d7a3ftrawick <strong>RewriteCond backreferences</strong>: These are
cf30286e95bd9b293bb4e3d5e4b89ed9d51d7a3ftrawick backreferences of the form <strong><code>%N</code></strong>
cf30286e95bd9b293bb4e3d5e4b89ed9d51d7a3ftrawick (0 <= N <= 9). %1 to %9 provide access to the grouped
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick parts (again, in parentheses) of the pattern, from the last matched
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick of conditions. %0 provides access to the whole string matched by
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick that pattern.
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick expansions of the form <strong><code>${mapname:key|default}</code></strong>.
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick RewriteMap</a> for more details.
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick <strong>Server-Variables</strong>: These are variables of
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick where <em>NAME_OF_VARIABLE</em> can be a string taken
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick from the following list:
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick <th>HTTP headers:</th> <th>connection & request:</th> <th />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick HTTP_USER_AGENT<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick HTTP_REFERER<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick HTTP_COOKIE<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick HTTP_FORWARDED<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick HTTP_HOST<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick HTTP_PROXY_CONNECTION<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick HTTP_ACCEPT<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick REMOTE_ADDR<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick REMOTE_HOST<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick REMOTE_PORT<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick REMOTE_USER<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick REMOTE_IDENT<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick REQUEST_METHOD<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick SCRIPT_FILENAME<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick PATH_INFO<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick QUERY_STRING<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick AUTH_TYPE<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick <th>server internals:</th> <th>date and time:</th> <th>specials:</th>
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick DOCUMENT_ROOT<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick SERVER_ADMIN<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick SERVER_NAME<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick SERVER_ADDR<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick SERVER_PORT<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick SERVER_PROTOCOL<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick SERVER_SOFTWARE<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick TIME_YEAR<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick TIME_MON<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick TIME_DAY<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick TIME_HOUR<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick TIME_MIN<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick TIME_SEC<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick TIME_WDAY<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick API_VERSION<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick THE_REQUEST<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick REQUEST_URI<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick REQUEST_FILENAME<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick IS_SUBREQ<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick HTTPS<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick REQUEST_SCHEME<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick <p>These variables all
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick correspond to the similarly named HTTP
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick MIME-headers, C variables of the Apache HTTP Server or
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick Most are documented elsewhere in the Manual or in
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick the CGI specification.</p>
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick <p>SERVER_NAME and SERVER_PORT depend on the values of
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick <code class="directive"><a href="/mod/core.html#usecanonicalname">UseCanonicalName</a></code> and
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick <code class="directive"><a href="/mod/core.html#usecanonicalphysicalport">UseCanonicalPhysicalPort</a></code>
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick respectively.</p>
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick <p>Those that are special to mod_rewrite include those below.</p>
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick <dd>Will contain the text "true" if the request
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick currently being processed is a sub-request,
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick "false" otherwise. Sub-requests may be generated
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick by modules that need to resolve additional files
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick or URIs in order to complete their tasks.</dd>
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick <dd>This is the version of the Apache httpd module API
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick (the internal interface between server and
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick module) in the current httpd build, as defined in
f6ba728fd666800e11b36452f7ad76ec5fcff653trawick corresponds to the version of Apache httpd in use (in
f6ba728fd666800e11b36452f7ad76ec5fcff653trawick the release version of Apache httpd 1.3.14, for
f6ba728fd666800e11b36452f7ad76ec5fcff653trawick instance, it is 19990320:10), but is mainly of
f6ba728fd666800e11b36452f7ad76ec5fcff653trawick interest to module authors.</dd>
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick <dd>The full HTTP request line sent by the
f6ba728fd666800e11b36452f7ad76ec5fcff653trawick include any additional headers sent by the
f6ba728fd666800e11b36452f7ad76ec5fcff653trawick browser. This value has not been unescaped
f6ba728fd666800e11b36452f7ad76ec5fcff653trawick (decoded), unlike most other variables below.</dd>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <dd>The path component of the requested URI,
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick such as "/index.html". This notably excludes the
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick query string which is available as as its own variable
61a4b32b1032d530e84e1131cb803f803acf7461trawick <dd>The full local filesystem path to the file or
d66e2366f1cceb0e2b107020fe61e36d090b6d9ctrawick script matching the request, if this has already
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick been determined by the server at the time
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <code>REQUEST_FILENAME</code> is referenced. Otherwise,
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick such as when used in virtual host context, the same
61a4b32b1032d530e84e1131cb803f803acf7461trawick <dd>Will contain the text "on" if the connection is
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick can be safely used regardless of whether or not
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <code class="module"><a href="/mod/mod_ssl.html">mod_ssl</a></code> is loaded).</dd>
4e12fead2bfdf613e0e2149f9f853edce6eab1fctrawick <dd>Will contain the scheme of the request (usually
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick "http" or "https"). This value can be influenced with
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <code class="directive"><a href="/mod/core.html#servername">ServerName</a></code>.</dd>
88c0d6d1cfdecfa8c2b6d7ae2482f06755cd7887trawick <p>If the <em>TestString</em> has the special value <code>expr</code>, the
d66e2366f1cceb0e2b107020fe61e36d090b6d9ctrawick <p>The variables SCRIPT_FILENAME and REQUEST_FILENAME
d66e2366f1cceb0e2b107020fe61e36d090b6d9ctrawick contain the same value - the value of the
d66e2366f1cceb0e2b107020fe61e36d090b6d9ctrawick <code>request_rec</code> structure of the Apache HTTP Server.
d66e2366f1cceb0e2b107020fe61e36d090b6d9ctrawick The first name is the commonly known CGI variable name
d66e2366f1cceb0e2b107020fe61e36d090b6d9ctrawick while the second is the appropriate counterpart of
a7b9ea00b96407cc3c1f3660162b3cb4918af396trawick REQUEST_URI (which contains the value of the
a7b9ea00b96407cc3c1f3660162b3cb4918af396trawick <code>uri</code> field of <code>request_rec</code>).</p>
a7b9ea00b96407cc3c1f3660162b3cb4918af396trawick <p>If a substitution occurred and the rewriting continues,
a7b9ea00b96407cc3c1f3660162b3cb4918af396trawick the value of both variables will be updated accordingly.</p>
a7b9ea00b96407cc3c1f3660162b3cb4918af396trawick <p>If used in per-server context (<em>i.e.</em>, before the
a7b9ea00b96407cc3c1f3660162b3cb4918af396trawick request is mapped to the filesystem) SCRIPT_FILENAME and
a7b9ea00b96407cc3c1f3660162b3cb4918af396trawick REQUEST_FILENAME cannot contain the full local filesystem
a7b9ea00b96407cc3c1f3660162b3cb4918af396trawick path since the path is unknown at this stage of processing.
a7b9ea00b96407cc3c1f3660162b3cb4918af396trawick Both variables will initially contain the value of REQUEST_URI
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick in that case. In order to obtain the full local filesystem
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick path of the request in per-server context, use an URL-based
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick look-ahead <code>%{LA-U:REQUEST_FILENAME}</code> to determine
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <code>%{ENV:variable}</code>, where <em>variable</em> can be
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick any environment variable, is also available.
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick This is looked-up via internal
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick Apache httpd structures and (if not found there) via
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <code>getenv()</code> from the Apache httpd server process.</li>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <code>%{SSL:variable}</code>, where <em>variable</em> is the
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick name of an <a href="mod_ssl.html#envvars">SSL environment
182d9b96e04124d14c9f539109fb4e8cbd360d36trawick variable</a>, can be used whether or not
182d9b96e04124d14c9f539109fb4e8cbd360d36trawick <code class="module"><a href="/mod/mod_ssl.html">mod_ssl</a></code> is loaded, but will always expand to
182d9b96e04124d14c9f539109fb4e8cbd360d36trawick the empty string if it is not. Example:
182d9b96e04124d14c9f539109fb4e8cbd360d36trawick <code>%{SSL:SSL_CIPHER_USEKEYSIZE}</code> may expand to
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <code>%{HTTP:header}</code>, where <em>header</em> can be
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick any HTTP MIME-header name, can always be used to obtain the
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick value of a header sent in the HTTP request.
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick the value of the HTTP header
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <p>If a HTTP header is used in a condition this header is added to
4e12fead2bfdf613e0e2149f9f853edce6eab1fctrawick the Vary header of the response in case the condition evaluates to
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick to true for the request. It is <strong>not</strong> added if the
61a4b32b1032d530e84e1131cb803f803acf7461trawick condition evaluates to false for the request. Adding the HTTP header
61a4b32b1032d530e84e1131cb803f803acf7461trawick to the Vary header of the response is needed for proper caching.</p>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <p>It has to be kept in mind that conditions follow a short circuit
e5819d621124ccc8ee3b7f1854c2d55ffaf91d32trawick logic in the case of the '<strong><code>ornext|OR</code></strong>' flag
88c0d6d1cfdecfa8c2b6d7ae2482f06755cd7887trawick so that certain conditions might not be evaluated at all.</p></li>
182d9b96e04124d14c9f539109fb4e8cbd360d36trawick <code>%{LA-U:variable}</code> can be used for look-aheads which perform
182d9b96e04124d14c9f539109fb4e8cbd360d36trawick an internal (URL-based) sub-request to determine the final
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick value of <em>variable</em>. This can be used to access
b4e664baba9a4be0457c31f84b3dcc4c31f2cb07kbrand variable for rewriting which is not available at the current
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick stage, but will be set in a later phase.
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <p>For instance, to rewrite according to the
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick per-server context (<code>httpd.conf</code> file) you must
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick variable is set by the authorization phases, which come
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <em>after</em> the URL translation phase (during which mod_rewrite
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick operates).</p>
fd8509fc63fd8e08579e509208377c2b76e29023trawick <p>On the other hand, because mod_rewrite implements
fd8509fc63fd8e08579e509208377c2b76e29023trawick its per-directory context (<code>.htaccess</code> file) via
fd8509fc63fd8e08579e509208377c2b76e29023trawick the Fixup phase of the API and because the authorization
fd8509fc63fd8e08579e509208377c2b76e29023trawick phases come <em>before</em> this phase, you just can use
fd8509fc63fd8e08579e509208377c2b76e29023trawick <code>%{REMOTE_USER}</code> in that context.</p></li>
182d9b96e04124d14c9f539109fb4e8cbd360d36trawick <code>%{LA-F:variable}</code> can be used to perform an internal
182d9b96e04124d14c9f539109fb4e8cbd360d36trawick (filename-based) sub-request, to determine the final value
182d9b96e04124d14c9f539109fb4e8cbd360d36trawick of <em>variable</em>. Most of the time, this is the same as
182d9b96e04124d14c9f539109fb4e8cbd360d36trawick LA-U above.</li>
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick a regular expression which is applied to the
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <em>TestString</em> is first evaluated, before being matched against
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <em>perl compatible regular expression</em>, but there is
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick additional syntax available to perform other useful tests against
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <li>You can prefix the pattern string with a
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick '<code>!</code>' character (exclamation mark) to specify a
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick You can perform lexicographical string comparisons:
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <li>'<strong><CondPattern</strong>' (lexicographically
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick precedes)<br />
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick Treats the <em>CondPattern</em> as a plain string and
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick compares it lexicographically to <em>TestString</em>. True if
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <li>'<strong>>CondPattern</strong>' (lexicographically
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick follows)<br />
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick Treats the <em>CondPattern</em> as a plain string and
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick compares it lexicographically to <em>TestString</em>. True if
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick <li>'<strong>=CondPattern</strong>' (lexicographically
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick equal)<br />
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick Treats the <em>CondPattern</em> as a plain string and
798cfee8074b529042079c77eee6962a723350detrawick compares it lexicographically to <em>TestString</em>. True if
798cfee8074b529042079c77eee6962a723350detrawick equal, character for character). If <em>CondPattern</em>
798cfee8074b529042079c77eee6962a723350detrawick compares <em>TestString</em> to the empty string.</li>
798cfee8074b529042079c77eee6962a723350detrawick <li>'<strong><=CondPattern</strong>' (lexicographically
798cfee8074b529042079c77eee6962a723350detrawick less than or equal to)<br />
798cfee8074b529042079c77eee6962a723350detrawick Treats the <em>CondPattern</em> as a plain string and
798cfee8074b529042079c77eee6962a723350detrawick compares it lexicographically to <em>TestString</em>. True
798cfee8074b529042079c77eee6962a723350detrawick <em>CondPattern</em>, or is equal to <em>CondPattern</em>
798cfee8074b529042079c77eee6962a723350detrawick (the two strings are equal, character for character).</li>
798cfee8074b529042079c77eee6962a723350detrawick <li>'<strong>>=CondPattern</strong>' (lexicographically
798cfee8074b529042079c77eee6962a723350detrawick greater than or equal to)<br />
798cfee8074b529042079c77eee6962a723350detrawick Treats the <em>CondPattern</em> as a plain string and
798cfee8074b529042079c77eee6962a723350detrawick compares it lexicographically to <em>TestString</em>. True
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <em>CondPattern</em>, or is equal to <em>CondPattern</em>
bc2c3a74fda3d3684ecb4a8a94ca03e5604ef670trawick (the two strings are equal, character for character).</li>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick You can perform integer comparisons:
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick The <em>TestString</em> is treated as an integer, and is
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick numerically compared to the <em>CondPattern</em>. True if
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick the two are numerically equal.</li>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <strong>g</strong>reater than or <strong>e</strong>qual to)<br />
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick The <em>TestString</em> is treated as an integer, and is
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick numerically compared to the <em>CondPattern</em>. True if
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick the <em>TestString</em> is numerically greater than or equal
798cfee8074b529042079c77eee6962a723350detrawick <strong>g</strong>reater <strong>t</strong>han)<br />
798cfee8074b529042079c77eee6962a723350detrawick The <em>TestString</em> is treated as an integer, and is
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick numerically compared to the <em>CondPattern</em>. True if
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <strong>l</strong>ess than or <strong>e</strong>qual to)<br />
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick The <em>TestString</em> is treated as an integer, and is
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick numerically compared to the <em>CondPattern</em>. True if
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick the <em>TestString</em> is numerically less than or equal
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick to the <em>CondPattern</em>. Avoid confusion with the
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <strong>-l</strong> by using the <strong>-L</strong> or
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick The <em>TestString</em> is treated as an integer, and is
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick numerically compared to the <em>CondPattern</em>. True if
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <strong>-l</strong> by using the <strong>-L</strong> or
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <li>You can perform various file attribute tests:
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick Treats the <em>TestString</em> as a pathname and tests
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick whether or not it exists, and is a directory.</li>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick Treats the <em>TestString</em> as a pathname and tests
5f29e9845e02a8c0a951dd81d6befa8cc76f53fbtrawick whether or not it exists, and is a regular file.</li>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick subrequest)<br />
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick Checks whether or not <em>TestString</em> is a valid file,
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick accessible via all the server's currently-configured
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick access controls for that path. This uses an internal
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick subrequest to do the check, so use it with care -
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick it can impact your server's performance!</li>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <li>'<strong>-H</strong>' (is symbolic link, bash convention)<br />
f6ba728fd666800e11b36452f7ad76ec5fcff653trawick Treats the <em>TestString</em> as a pathname and tests
f6ba728fd666800e11b36452f7ad76ec5fcff653trawick whether or not it exists, and is a symbolic link. May also
8b69a6447203b4cbd4c063010092dbe931503644trawick <strong>-h</strong> if there's a possibility of confusion
8b69a6447203b4cbd4c063010092dbe931503644trawick <li>'<strong>-L</strong>' (is symbolic link, bash convention)<br />
8b69a6447203b4cbd4c063010092dbe931503644trawick Treats the <em>TestString</em> as a pathname and tests
f6ba728fd666800e11b36452f7ad76ec5fcff653trawick whether or not it exists, and is a regular file with size greater
f6ba728fd666800e11b36452f7ad76ec5fcff653trawick than zero.</li>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick subrequest)<br />
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick Checks whether or not <em>TestString</em> is a valid URL,
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick accessible via all the server's currently-configured
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick access controls for that path. This uses an internal
bbd9d609b3e1f45b4a5beda3ef5e8a589b3657b4trawick subrequest to do the check, so use it with care -
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick it can impact your server's performance!</li>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <li>'<strong>-x</strong>' (has e<strong>x</strong>ecutable
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick permissions)<br />
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick Treats the <em>TestString</em> as a pathname and tests
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick whether or not it exists, and has executable permissions.
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick These permissions are determined according to
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick the underlying OS.</li>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick All of these tests can
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick also be prefixed by an exclamation mark ('!') to
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick negate their meaning.
6500ceb45a2075fad36a0dc5c86a23858bf9c84etrawick <p>If the <em>TestString</em> has the special value <code>expr</code>, the
6500ceb45a2075fad36a0dc5c86a23858bf9c84etrawick In the below example, <code>-strmatch</code> is used to
6500ceb45a2075fad36a0dc5c86a23858bf9c84etrawick compare the <code>REFERER</code> against the site hostname,
6500ceb45a2075fad36a0dc5c86a23858bf9c84etrawick to block unwanted hotlinking.
6500ceb45a2075fad36a0dc5c86a23858bf9c84etrawick RewriteCond expr "! %{HTTP_REFERER} -strmatch '*://%{HTTP_HOST}/*'"<br />
6500ceb45a2075fad36a0dc5c86a23858bf9c84etrawick RewriteRule ^/images - [F]
6500ceb45a2075fad36a0dc5c86a23858bf9c84etrawick <li>You can also set special flags for
6500ceb45a2075fad36a0dc5c86a23858bf9c84etrawick <strong><code>[</code><em>flags</em><code>]</code></strong>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick as the third argument to the <code>RewriteCond</code>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick directive, where <em>flags</em> is a comma-separated list of any of the
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick following flags:
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick This makes the test case-insensitive - differences
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick between 'A-Z' and 'a-z' are ignored, both in the
e6114dbc138189372015ea6ed63bc757645922a7trawick expanded <em>TestString</em> and the <em>CondPattern</em>.
e6114dbc138189372015ea6ed63bc757645922a7trawick This flag is effective only for comparisons between
e6114dbc138189372015ea6ed63bc757645922a7trawick <em>TestString</em> and <em>CondPattern</em>. It has no
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick effect on filesystem and subrequest checks.</li>
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick Use this to combine rule conditions with a local OR
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick instead of the implicit AND. Typical example:
88c0d6d1cfdecfa8c2b6d7ae2482f06755cd7887trawickRewriteCond %{REMOTE_HOST} ^host1 [OR]
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawickRewriteCond %{REMOTE_HOST} ^host2 [OR]
e5819d621124ccc8ee3b7f1854c2d55ffaf91d32trawickRewriteCond %{REMOTE_HOST} ^host3
e5819d621124ccc8ee3b7f1854c2d55ffaf91d32trawickRewriteRule ...some special stuff for any of these hosts...
e5819d621124ccc8ee3b7f1854c2d55ffaf91d32trawick Without this flag you would have to write the condition/rule
e5819d621124ccc8ee3b7f1854c2d55ffaf91d32trawick pair three times.
88c0d6d1cfdecfa8c2b6d7ae2482f06755cd7887trawick If a HTTP header is used in the condition, this flag prevents
88c0d6d1cfdecfa8c2b6d7ae2482f06755cd7887trawick this header from being added to the Vary header of the response. <br />
88c0d6d1cfdecfa8c2b6d7ae2482f06755cd7887trawick Using this flag might break proper caching of the response if
1f5a6b18eb1d06210b03a7c8ea7a07506f5949ddtrawick the representation of this response varies on the value of this header.
88c0d6d1cfdecfa8c2b6d7ae2482f06755cd7887trawick So this flag should be only used if the meaning of the Vary header
88c0d6d1cfdecfa8c2b6d7ae2482f06755cd7887trawick is well understood.
88c0d6d1cfdecfa8c2b6d7ae2482f06755cd7887trawick <p>To rewrite the Homepage of a site according to the
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick ``<code>User-Agent:</code>'' header of the request, you can
e6114dbc138189372015ea6ed63bc757645922a7trawick use the following: </p>
88c0d6d1cfdecfa8c2b6d7ae2482f06755cd7887trawickRewriteCond %{HTTP_USER_AGENT} ^Mozilla
a63c98c28033ca762ca4dcbed6b3adef63580e7ctrawickRewriteRule ^/$ /homepage.max.html [L]
88c0d6d1cfdecfa8c2b6d7ae2482f06755cd7887trawickRewriteCond %{HTTP_USER_AGENT} ^Lynx
a63c98c28033ca762ca4dcbed6b3adef63580e7ctrawickRewriteRule ^/$ /homepage.min.html [L]
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawickRewriteRule ^/$ /homepage.std.html [L]
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <p>Explanation: If you use a browser which identifies itself
d66e2366f1cceb0e2b107020fe61e36d090b6d9ctrawick as 'Mozilla' (including Netscape Navigator, Mozilla etc), then you
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick get the max homepage (which could include frames, or other special
d66e2366f1cceb0e2b107020fe61e36d090b6d9ctrawick If you use the Lynx browser (which is terminal-based), then
1b7ea70f150ac2343f7086af4df0b81749885eb1trawick you get the min homepage (which could be a version designed for
d66e2366f1cceb0e2b107020fe61e36d090b6d9ctrawick easy, text-only browsing).
d66e2366f1cceb0e2b107020fe61e36d090b6d9ctrawick If neither of these conditions apply (you use any other browser,
d66e2366f1cceb0e2b107020fe61e36d090b6d9ctrawick or your browser identifies itself as something non-standard), you get
d66e2366f1cceb0e2b107020fe61e36d090b6d9ctrawick the std (standard) homepage.</p>
4e12fead2bfdf613e0e2149f9f853edce6eab1fctrawick<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
4e12fead2bfdf613e0e2149f9f853edce6eab1fctrawick<div class="directive-section"><h2><a name="RewriteEngine" id="RewriteEngine">RewriteEngine</a> <a name="rewriteengine" id="rewriteengine">Directive</a></h2>
4e12fead2bfdf613e0e2149f9f853edce6eab1fctrawick<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Enables or disables runtime rewriting engine</td></tr>
4e12fead2bfdf613e0e2149f9f853edce6eab1fctrawick<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteEngine on|off</code></td></tr>
4e12fead2bfdf613e0e2149f9f853edce6eab1fctrawick<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>RewriteEngine off</code></td></tr>
4e12fead2bfdf613e0e2149f9f853edce6eab1fctrawick<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
bc2c3a74fda3d3684ecb4a8a94ca03e5604ef670trawick<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
bc2c3a74fda3d3684ecb4a8a94ca03e5604ef670trawick<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
bbd9d609b3e1f45b4a5beda3ef5e8a589b3657b4trawick <p>The <code class="directive">RewriteEngine</code> directive enables or
bbd9d609b3e1f45b4a5beda3ef5e8a589b3657b4trawick disables the runtime rewriting engine. If it is set to
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <code>off</code> this module does no runtime processing at
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick all. It does not even update the <code>SCRIPT_URx</code>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick environment variables.</p>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <p>Use this directive to disable the module instead of
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick commenting out all the <code class="directive"><a href="#rewriterule">RewriteRule</a></code> directives!</p>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <p>Note that rewrite configurations are not
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick inherited by virtual hosts. This means that you need to have a
182d9b96e04124d14c9f539109fb4e8cbd360d36trawick <code>RewriteEngine on</code> directive for each virtual host
633bb5999839dd4433603525a2b76dc3be6df8f4trawick in which you wish to use rewrite rules.</p>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <p><code class="directive">RewriteMap</code> directives of the type <code>prg</code>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick are not started during server initialization if they're defined in a
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick context that does not have <code class="directive">RewriteEngine</code> set to
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
5a2741099e61f454d3071092ae7e606418e5809atrawick<div class="directive-section"><h2><a name="RewriteMap" id="RewriteMap">RewriteMap</a> <a name="rewritemap" id="rewritemap">Directive</a></h2>
bc2c3a74fda3d3684ecb4a8a94ca03e5604ef670trawick<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Defines a mapping function for key-lookup</td></tr>
bc2c3a74fda3d3684ecb4a8a94ca03e5604ef670trawick<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteMap <em>MapName</em> <em>MapType</em>:<em>MapSource</em>
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
bbd9d609b3e1f45b4a5beda3ef5e8a589b3657b4trawick<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
5a2741099e61f454d3071092ae7e606418e5809atrawick<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
8b69a6447203b4cbd4c063010092dbe931503644trawick<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>The choice of different dbm types is available in
8b69a6447203b4cbd4c063010092dbe931503644trawick <p>The <code class="directive">RewriteMap</code> directive defines a
bbd9d609b3e1f45b4a5beda3ef5e8a589b3657b4trawick <em>Rewriting Map</em> which can be used inside rule
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick substitution strings by the mapping-functions to
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick insert/substitute fields through a key lookup. The source of
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick this lookup can be of various types.</p>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <p>The <a id="mapfunc" name="mapfunc"><em>MapName</em></a> is
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick the name of the map and will be used to specify a
bbd9d609b3e1f45b4a5beda3ef5e8a589b3657b4trawick mapping-function for the substitution strings of a rewriting
bbd9d609b3e1f45b4a5beda3ef5e8a589b3657b4trawick rule via one of the following constructs:</p>
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick <strong><code>${</code> <em>MapName</em> <code>:</code>
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick <em>LookupKey</em> <code>|</code> <em>DefaultValue</em>
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick <p>When such a construct occurs, the map <em>MapName</em> is
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick consulted and the key <em>LookupKey</em> is looked-up. If the
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick key is found, the map-function construct is substituted by
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick <em>SubstValue</em>. If the key is not found then it is
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick substituted by <em>DefaultValue</em> or by the empty string
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick if no <em>DefaultValue</em> was specified. Empty values
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick behave as if the key was absent, therefore it is not possible
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick to distinguish between empty-valued keys and absent keys.</p>
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick <p>For example, you might define a
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick <p>You would then be able to use this map in a
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick <code class="directive">RewriteRule</code> as follows:</p>
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick RewriteRule ^/ex/(.*) ${examplemap:$1}
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <p>The following combinations for <em>MapType</em> and
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <dd>A plain text file containing space-separated key-value
bbd9d609b3e1f45b4a5beda3ef5e8a589b3657b4trawick pairs, one per line. (<a href="/rewrite/rewritemap.html#txt">Details ...</a>)</dd>
a63c98c28033ca762ca4dcbed6b3adef63580e7ctrawick <dd>Randomly selects an entry from a plain text file (<a href="/rewrite/rewritemap.html#rnd">Details ...</a>)</dd>
a63c98c28033ca762ca4dcbed6b3adef63580e7ctrawick <dd>Looks up an entry in a dbm file containing name, value
a63c98c28033ca762ca4dcbed6b3adef63580e7ctrawick pairs. Hash is constructed from a plain text file format using
a63c98c28033ca762ca4dcbed6b3adef63580e7ctrawick the <code><a href="/programs/httxt2dbm.html">httxt2dbm</a></code>
a63c98c28033ca762ca4dcbed6b3adef63580e7ctrawick utility. (<a href="/rewrite/rewritemap.html#dbm">Details ...</a>)</dd>
a63c98c28033ca762ca4dcbed6b3adef63580e7ctrawick <dd>One of the four available internal functions provided by
a63c98c28033ca762ca4dcbed6b3adef63580e7ctrawick <code>RewriteMap</code>: toupper, tolower, escape or
a63c98c28033ca762ca4dcbed6b3adef63580e7ctrawick unescape. (<a href="/rewrite/rewritemap.html#int">Details ...</a>)</dd>
a63c98c28033ca762ca4dcbed6b3adef63580e7ctrawick <dd>Calls an external program or script to process the
a63c98c28033ca762ca4dcbed6b3adef63580e7ctrawick rewriting. (<a href="/rewrite/rewritemap.html#prg">Details ...</a>)</dd>
a63c98c28033ca762ca4dcbed6b3adef63580e7ctrawick <dd>A SQL SELECT statement to be performed to look up the
a63c98c28033ca762ca4dcbed6b3adef63580e7ctrawick rewrite target. (<a href="/rewrite/rewritemap.html#dbd">Details ...</a>)</dd>
a63c98c28033ca762ca4dcbed6b3adef63580e7ctrawick <p>Further details, and numerous examples, may be found in the <a href="/rewrite/rewritemap.html">RewriteMap HowTo</a></p>
a63c98c28033ca762ca4dcbed6b3adef63580e7ctrawick<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
a63c98c28033ca762ca4dcbed6b3adef63580e7ctrawick<div class="directive-section"><h2><a name="RewriteOptions" id="RewriteOptions">RewriteOptions</a> <a name="rewriteoptions" id="rewriteoptions">Directive</a></h2>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets some special options for the rewrite engine</td></tr>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteOptions <var>Options</var></code></td></tr>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td><code>MaxRedirects</code> is no longer available in version 2.1 and
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick <p>The <code class="directive">RewriteOptions</code> directive sets some
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick special options for the current per-server or per-directory
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick configuration. The <em>Option</em> string can currently
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick only be one of the following:</p>
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick <p>This forces the current configuration to inherit the
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick configuration of the parent. In per-virtual-server context,
6500ceb45a2075fad36a0dc5c86a23858bf9c84etrawick this means that the maps, conditions and rules of the main
4e12fead2bfdf613e0e2149f9f853edce6eab1fctrawick server are inherited. In per-directory context this means
4e12fead2bfdf613e0e2149f9f853edce6eab1fctrawick that conditions and rules of the parent directory's
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick <code class="directive"><a href="/mod/core.html#directory"><Directory></a></code>
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick sections are inherited. The inherited rules are virtually copied
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick to the section where this directive is being used. If used in
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick combination with local rules, the inherited rules are copied behind
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick the local rules. The position of this directive - below or above
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick of local rules - has no influence on this behavior. If local
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick rules forced the rewriting to stop, the inherited rules won't
a8002cb6eb5309086e06721eb2cdc20b891840fftrawick be processed.</p>
a63c98c28033ca762ca4dcbed6b3adef63580e7ctrawick Rules inherited from the parent scope are applied
a8002cb6eb5309086e06721eb2cdc20b891840fftrawick <strong>after</strong> rules specified in the child scope.
a63c98c28033ca762ca4dcbed6b3adef63580e7ctrawick <p> Like <code>Inherit</code> above, but the rules from the parent scope
a63c98c28033ca762ca4dcbed6b3adef63580e7ctrawick are applied <strong>before</strong> rules specified in the child scope.
a63c98c28033ca762ca4dcbed6b3adef63580e7ctrawick Available in Apache HTTP Server 2.3.10 and later.</p>
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick <p>By default, <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> will ignore URLs that map to a
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick directory on disk but lack a trailing slash, in the expectation that
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick the <code class="module"><a href="/mod/mod_dir.html">mod_dir</a></code> module will issue the client with a redirect to
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick the canonical URL with a trailing slash.</p>
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick <p>When the <code class="directive"><a href="/mod/mod_dir.html#directoryslash">DirectorySlash</a></code> directive
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick is set to off, the <code>AllowNoSlash</code> option can be enabled to ensure
0ce6a6bda16e6c66ee68cc9784db36cc1bd558a7trawick that rewrite rules are no longer ignored. This option makes it possible to
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick apply rewrite rules within .htaccess files that match the directory without
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick a trailing slash, if so desired. Available in Apache HTTP Server 2.4.0 and
bbd9d609b3e1f45b4a5beda3ef5e8a589b3657b4trawick <p>When <code class="directive"><a href="#rewriterule">RewriteRule</a></code>
bbd9d609b3e1f45b4a5beda3ef5e8a589b3657b4trawick is used in <code>VirtualHost</code> or server context with
bbd9d609b3e1f45b4a5beda3ef5e8a589b3657b4trawick version 2.2.22 or later of httpd, <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code>
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick will only process the rewrite rules if the request URI is a <a href="/directive-dict.html#Syntax">URL-path</a>. This avoids
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick some security issues where particular rules could allow
e6114dbc138189372015ea6ed63bc757645922a7trawick "surprising" pattern expansions (see <a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-3368">CVE-2011-3368</a>
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick and <a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-4317">CVE-2011-4317</a>).
e6114dbc138189372015ea6ed63bc757645922a7trawick To lift the restriction on matching a URL-path, the
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> will apply the rule set to any
e6114dbc138189372015ea6ed63bc757645922a7trawick request URI string, regardless of whether that string matches
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick the URL-path grammar required by the HTTP specification.</p>
4e2fbd7af73349caa41681acc2ec43d6d7011beatrawick <p>Enabling this option will make the server vulnerable to
fcd5c4e9e126e867eb270ed2d4138348cb1e46e5trawick security issues if used with rewrite rules which are not
<div class="directive-section"><h2><a name="RewriteRule" id="RewriteRule">RewriteRule</a> <a name="rewriterule" id="rewriterule">Directive</a></h2>
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Defines rules for the rewriting engine</td></tr>
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
<p>In <code class="directive"><a href="/mod/core.html#directory">Directory</a></code> and htaccess context,
<li>The rewrite engine may be used in <a href="/howto/htaccess.html">.htaccess</a> files and in <code class="directive"><a href="/mod/core.html#directory"><Directory></a></code> sections, with some additional
<li>Although rewrite rules are syntactically permitted in <code class="directive"><a href="/mod/core.html#location"><Location></a></code> and <code class="directive"><a href="/mod/core.html#files"><Files></a></code> sections, this
<p>For some hints on <a class="glossarylink" href="/glossary.html#regex" title="see glossary">regular
<dd>A <code class="directive"><a href="/mod/core.html#documentroot">DocumentRoot</a></code>-relative path to the
resource to be served. Note that <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code>
URL-mapping directives (such as <code class="directive"><a href="/mod/mod_alias.html#alias">Alias</a></code>) to be applied to the
<code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> checks to see whether the
in the config file. The URL-path or file-system path (see <a href="#what_is_matched">"What is matched?"</a>, above) is <strong>completely
<p>Additionally you can set special <a name="rewriteflags" id="rewriteflags">actions</a> to be performed by
details, and examples, for each flag, are available in the <a href="/rewrite/flags.html">Rewrite Flags document</a>.</p>
the rule(s) chained to it will be skipped. <em><a href="/rewrite/flags.html#flag_c">details ...</a></em></td>
CO=<em>NAME</em>:<em>VAL</em>:<em>domain</em>[:<em>lifetime</em>[:<em>path</em>[:<em>secure</em>[:<em>httponly</em>]]]] <em><a href="/rewrite/flags.html#flag_co">details ...</a></em>
the environment variable <em>VAR</em> to be unset.<em><a href="/rewrite/flags.html#flag_e">details ...</a></em></td>
<td>Returns a 410 GONE response to the client browser. <em><a href="/rewrite/flags.html#flag_g">details ...</a></em></td>
<em>Content-handler</em> for processing. <em><a href="/rewrite/flags.html#flag_h">details ...</a></em></td>
.htaccess context (see also the END flag). <em><a href="/rewrite/flags.html#flag_l">details ...</a></em></td>
special characters in the result of the rewrite. <em><a href="/rewrite/flags.html#flag_ne">details ...</a></em></td>
any query string created in the rewrite target.<em><a href="/rewrite/flags.html#flag_qsa">details ...</a></em></td>
rules if the current rule matches. <em><a href="/rewrite/flags.html#flag_s">details ...</a></em></td>
<td>Force the <a class="glossarylink" href="/glossary.html#mime-type" title="see glossary">MIME-type</a> of the target file
<p><span>Available Languages: </span><a href="/en/mod/mod_rewrite.html" title="English"> en </a> |
<a href="/fr/mod/mod_rewrite.html" hreflang="fr" rel="alternate" title="Fran�ais"> fr </a></p>
</div><div class="top"><a href="#page-header"><img src="/images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
var comments_identifier = 'http://httpd.apache.org/docs/trunk/mod/mod_rewrite.html';
if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
d.write('<div id="comments_thread"><\/div>');
var s = d.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
(d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
<p class="apache">Copyright 2012 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--