mod_rewrite.html.en revision c0a201f9f0cda37f4e5829462c7e489f85bf327c
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<?xml version="1.0" encoding="ISO-8859-1"?>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe This file is generated from xml source: DO NOT EDIT
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe -->
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<title>mod_rewrite - Apache HTTP Server</title>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<link href="/images/favicon.ico" rel="shortcut icon" /></head>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<body>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div id="page-header">
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<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>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<p class="apache">Apache HTTP Server Version 2.3</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<img alt="" src="/images/feather.gif" /></div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="/images/left.gif" /></a></div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div id="path">
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<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>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div id="page-content">
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div id="preamble"><h1>Apache Module mod_rewrite</h1>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="toplang">
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<p><span>Available Languages: </span><a href="/en/mod/mod_rewrite.html" title="English">&nbsp;en&nbsp;</a> |
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<a href="/fr/mod/mod_rewrite.html" hreflang="fr" rel="alternate" title="Fran�ais">&nbsp;fr&nbsp;</a></p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Provides a rule-based rewriting engine to rewrite requested
ceaa05c302b4a0013174f4344c0907df84f7390dwroweURLs on the fly</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="module-dict.html#Status">Status:</a></th><td>Extension</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="module-dict.html#ModuleIdentifier">Module�Identifier:</a></th><td>rewrite_module</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="module-dict.html#SourceFile">Source�File:</a></th><td>mod_rewrite.c</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="module-dict.html#Compatibility">Compatibility:</a></th><td>Available in Apache 1.3 and later</td></tr></table>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<h3>Summary</h3>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>The <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> module uses a rule-based rewriting
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe engine, based on a regular-expression parser, to rewrite requested URLs on
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe the fly. By default, <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> maps a URL to a filesystem
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe path. However, it can also be used to redirect one URL to another URL, or
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe to invoke an internal proxy fetch.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p><code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> provides a flexible and powerful way to
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe manipulate URLs using an unlimited number of rules. Each rule can have an
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe unlimited number of attached rule conditions, to allow you to rewrite URL
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe based on server variables, environment variables, HTTP headers, or time
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe stamps.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p><code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> operates on the full URL path, including the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe path-info section. A rewrite rule can be invoked in
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>httpd.conf</code> or in <code>.htaccess</code>. The path generated
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe by a rewrite rule can include a query string, or can lead to internal
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe sub-processing, external request redirection, or internal proxy
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe throughput.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>Further details, discussion, and examples, are provided in the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <a href="/rewrite/">detailed mod_rewrite documentation</a>.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div id="quickview"><h3 class="directives">Directives</h3>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<ul id="toc">
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<li><img alt="" src="/images/down.gif" /> <a href="#rewritebase">RewriteBase</a></li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<li><img alt="" src="/images/down.gif" /> <a href="#rewritecond">RewriteCond</a></li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<li><img alt="" src="/images/down.gif" /> <a href="#rewriteengine">RewriteEngine</a></li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<li><img alt="" src="/images/down.gif" /> <a href="#rewritelog">RewriteLog</a></li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<li><img alt="" src="/images/down.gif" /> <a href="#rewriteloglevel">RewriteLogLevel</a></li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<li><img alt="" src="/images/down.gif" /> <a href="#rewritemap">RewriteMap</a></li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<li><img alt="" src="/images/down.gif" /> <a href="#rewriteoptions">RewriteOptions</a></li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<li><img alt="" src="/images/down.gif" /> <a href="#rewriterule">RewriteRule</a></li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</ul>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="directive-section"><h2><a name="RewriteBase" id="RewriteBase">RewriteBase</a> <a name="rewritebase" id="rewritebase">Directive</a></h2>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<table class="directive">
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets the base URL for per-directory rewrites</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteBase <em>URL-path</em></code></td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>None</code></td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>directory, .htaccess</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</table>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>The <code class="directive">RewriteBase</code> directive explicitly
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe sets the base URL-path (not filesystem directory path!) for per-directory rewrites.
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe When you use a <code class="directive"><a href="#rewriterule">RewriteRule</a></code>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe in a <code>.htaccess</code> file, <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> strips off
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe the local directory prefix before processing, then rewrites the rest of
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe the URL. When the rewrite is completed, <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe automatically adds the local directory prefix back on to the path.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>This directive is <em>required</em> for per-directory rewrites whose context
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe is a directory made available via the <code class="directive"><a href="/mod/mod_alias.html#alias">Alias</a></code>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe directive.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>If your URL path does not exist verbatim on the filesystem,
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe or isn't directly under your <code class="directive"><a href="/mod/core.html#documentroot">DocumentRoot</a></code>,
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe you must use <code class="directive">RewriteBase</code> in every
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>.htaccess</code> file where you want to use <code class="directive"><a href="#rewriterule">RewriteRule</a></code> directives.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>The example below demonstrates how to map
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe http://example.com/myapp/index.html to
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe /home/www/example/newsite.html, in a <code>.htaccess</code> file. This
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe assumes that the content available at
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe http://example.com/ is on disk at /home/www/example/</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="example"><pre>
ceaa05c302b4a0013174f4344c0907df84f7390dwroweRewriteEngine On
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe# The URL-path used to get to this context, not the filesystem path
ceaa05c302b4a0013174f4344c0907df84f7390dwroweRewriteBase /myapp/
ceaa05c302b4a0013174f4344c0907df84f7390dwroweRewriteRule ^index\.html$ newsite.html
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</pre></div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="directive-section"><h2><a name="RewriteCond" id="RewriteCond">RewriteCond</a> <a name="rewritecond" id="rewritecond">Directive</a></h2>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<table class="directive">
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Defines a condition under which rewriting will take place
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code> RewriteCond
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em>TestString</em> <em>CondPattern</em></code></td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</table>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>The <code class="directive">RewriteCond</code> directive defines a
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe rule condition. One or more <code class="directive">RewriteCond</code>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe can precede a <code class="directive"><a href="#rewriterule">RewriteRule</a></code>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe directive. The following rule is then only used if both
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg the current state of the URI matches its pattern, <strong>and</strong> if these conditions are met.</p>
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg <p><em>TestString</em> is a string which can contain the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe following expanded constructs in addition to plain text:</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <ul>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <strong>RewriteRule backreferences</strong>: These are
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe backreferences of the form <strong><code>$N</code></strong>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe (0 &lt;= N &lt;= 9). $1 to $9 provide access to the grouped
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe parts (in parentheses) of the pattern, from the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>RewriteRule</code> which is subject to the current
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe set of <code>RewriteCond</code> conditions. $0 provides
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe access to the whole string matched by that pattern.
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <strong>RewriteCond backreferences</strong>: These are
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe backreferences of the form <strong><code>%N</code></strong>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe (0 &lt;= N &lt;= 9). %1 to %9 provide access to the grouped
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe parts (again, in parentheses) of the pattern, from the last matched
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>RewriteCond</code> in the current set
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe of conditions. %0 provides access to the whole string matched by
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe that pattern.
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <strong>RewriteMap expansions</strong>: These are
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe expansions of the form <strong><code>${mapname:key|default}</code></strong>.
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe See <a href="#mapfunc">the documentation for
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe RewriteMap</a> for more details.
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <strong>Server-Variables</strong>: These are variables of
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe the form
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <strong><code>%{</code> <em>NAME_OF_VARIABLE</em>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>}</code></strong>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe where <em>NAME_OF_VARIABLE</em> can be a string taken
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe from the following list:
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <table>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <th>HTTP headers:</th> <th>connection &amp; request:</th> <th />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe HTTP_USER_AGENT<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe HTTP_REFERER<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe HTTP_COOKIE<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe HTTP_FORWARDED<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe HTTP_HOST<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe HTTP_PROXY_CONNECTION<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe HTTP_ACCEPT<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe REMOTE_ADDR<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe REMOTE_HOST<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe REMOTE_PORT<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe REMOTE_USER<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe REMOTE_IDENT<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe REQUEST_METHOD<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe SCRIPT_FILENAME<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe PATH_INFO<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe QUERY_STRING<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe AUTH_TYPE<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <th>server internals:</th> <th>date and time:</th> <th>specials:</th>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe DOCUMENT_ROOT<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe SERVER_ADMIN<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe SERVER_NAME<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe SERVER_ADDR<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe SERVER_PORT<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe SERVER_PROTOCOL<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe SERVER_SOFTWARE<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe TIME_YEAR<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe TIME_MON<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe TIME_DAY<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe TIME_HOUR<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe TIME_MIN<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe TIME_SEC<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe TIME_WDAY<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe TIME<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe API_VERSION<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe THE_REQUEST<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe REQUEST_URI<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe REQUEST_FILENAME<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe IS_SUBREQ<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe HTTPS<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </table>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>These variables all
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe correspond to the similarly named HTTP
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe MIME-headers, C variables of the Apache server or
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg <code>struct tm</code> fields of the Unix system.
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg Most are documented elsewhere in the Manual or in
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg the CGI specification. Those that are special to
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe mod_rewrite include those below.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <div class="note">
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <dl>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <dt><code>IS_SUBREQ</code></dt>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <dd>Will contain the text "true" if the request
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe currently being processed is a sub-request,
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe "false" otherwise. Sub-requests may be generated
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe by modules that need to resolve additional files
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe or URIs in order to complete their tasks.</dd>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <dt><code>API_VERSION</code></dt>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <dd>This is the version of the Apache module API
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe (the internal interface between server and
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe module) in the current httpd build, as defined in
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe include/ap_mmn.h. The module API version
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe corresponds to the version of Apache in use (in
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe the release version of Apache 1.3.14, for
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe instance, it is 19990320:10), but is mainly of
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe interest to module authors.</dd>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <dt><code>THE_REQUEST</code></dt>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg <dd>The full HTTP request line sent by the
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg browser to the server (e.g., "<code>GET
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg /index.html HTTP/1.1</code>"). This does not
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe include any additional headers sent by the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe browser.</dd>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <dt><code>REQUEST_URI</code></dt>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <dd>The resource requested in the HTTP request
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe line. (In the example above, this would be
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe "/index.html".)</dd>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <dt><code>REQUEST_FILENAME</code></dt>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <dd>The full local filesystem path to the file or
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe script matching the request, if this has already
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe been determined by the server at the time
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>REQUEST_FILENAME</code> is referenced. Otherwise,
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe such as when used in virtual host context, the same
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe value as <code>REQUEST_URI</code>.</dd>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <dt><code>HTTPS</code></dt>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <dd>Will contain the text "on" if the connection is
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe using SSL/TLS, or "off" otherwise. (This variable
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe can be safely used regardless of whether or not
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code class="module"><a href="/mod/mod_ssl.html">mod_ssl</a></code> is loaded).</dd>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </dl>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </ul>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>Other things you should be aware of:</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <ol>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>The variables SCRIPT_FILENAME and REQUEST_FILENAME
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe contain the same value - the value of the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>filename</code> field of the internal
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>request_rec</code> structure of the Apache server.
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe The first name is the commonly known CGI variable name
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe while the second is the appropriate counterpart of
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe REQUEST_URI (which contains the value of the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>uri</code> field of <code>request_rec</code>).</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>If a substitution occurred and the rewriting continues,
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe the value of both variables will be updated accordingly.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>If used in per-server context (<em>i.e.</em>, before the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe request is mapped to the filesystem) SCRIPT_FILENAME and
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe REQUEST_FILENAME cannot contain the full local filesystem
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe path since the path is unknown at this stage of processing.
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe Both variables will initially contain the value of REQUEST_URI
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe in that case. In order to obtain the full local filesystem
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe path of the request in per-server context, use an URL-based
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe look-ahead <code>%{LA-U:REQUEST_FILENAME}</code> to determine
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe the final value of REQUEST_FILENAME.</p></li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>%{ENV:variable}</code>, where <em>variable</em> can be
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe any environment variable, is also available.
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe This is looked-up via internal
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe Apache structures and (if not found there) via
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>getenv()</code> from the Apache server process.</li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>%{SSL:variable}</code>, where <em>variable</em> is the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe name of an <a href="mod_ssl.html#envvars">SSL environment
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe variable</a>, can be used whether or not
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code class="module"><a href="/mod/mod_ssl.html">mod_ssl</a></code> is loaded, but will always expand to
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe the empty string if it is not. Example:
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>%{SSL:SSL_CIPHER_USEKEYSIZE}</code> may expand to
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>128</code>.</li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>%{HTTP:header}</code>, where <em>header</em> can be
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe any HTTP MIME-header name, can always be used to obtain the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe value of a header sent in the HTTP request.
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe Example: <code>%{HTTP:Proxy-Connection}</code> is
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe the value of the HTTP header
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe ``<code>Proxy-Connection:</code>''.
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>If a HTTP header is used in a condition this header is added to
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe the Vary header of the response in case the condition evaluates to
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe to true for the request. It is <strong>not</strong> added if the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe condition evaluates to false for the request. Adding the HTTP header
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe to the Vary header of the response is needed for proper caching.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>It has to be kept in mind that conditions follow a short circuit
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe logic in the case of the '<strong><code>ornext|OR</code></strong>' flag
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe so that certain conditions might not be evaluated at all.</p></li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>%{LA-U:variable}</code> can be used for look-aheads which perform
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe an internal (URL-based) sub-request to determine the final
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe value of <em>variable</em>. This can be used to access
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe variable for rewriting which is not available at the current
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe stage, but will be set in a later phase.
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>For instance, to rewrite according to the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>REMOTE_USER</code> variable from within the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe per-server context (<code>httpd.conf</code> file) you must
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe use <code>%{LA-U:REMOTE_USER}</code> - this
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe variable is set by the authorization phases, which come
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em>after</em> the URL translation phase (during which mod_rewrite
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe operates).</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>On the other hand, because mod_rewrite implements
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe its per-directory context (<code>.htaccess</code> file) via
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe the Fixup phase of the API and because the authorization
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe phases come <em>before</em> this phase, you just can use
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>%{REMOTE_USER}</code> in that context.</p></li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>%{LA-F:variable}</code> can be used to perform an internal
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe (filename-based) sub-request, to determine the final value
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe of <em>variable</em>. Most of the time, this is the same as
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe LA-U above.</li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </ol>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p><em>CondPattern</em> is the condition pattern,
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe a regular expression which is applied to the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe current instance of the <em>TestString</em>.
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em>TestString</em> is first evaluated, before being matched against
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em>CondPattern</em>.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p><strong>Remember:</strong> <em>CondPattern</em> is a
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em>perl compatible regular expression</em> with some
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe additions:</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <ol>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>You can prefix the pattern string with a
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe '<code>!</code>' character (exclamation mark) to specify a
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <strong>non</strong>-matching pattern.</li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe There are some special variants of <em>CondPatterns</em>.
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe Instead of real regular expression strings you can also
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe use one of the following:
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <ul>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>'<strong>&lt;CondPattern</strong>' (lexicographically
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe precedes)<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe Treats the <em>CondPattern</em> as a plain string and
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe compares it lexicographically to <em>TestString</em>. True if
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em>TestString</em> lexicographically precedes
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em>CondPattern</em>.</li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>'<strong>&gt;CondPattern</strong>' (lexicographically
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe follows)<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe Treats the <em>CondPattern</em> as a plain string and
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe compares it lexicographically to <em>TestString</em>. True if
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em>TestString</em> lexicographically follows
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em>CondPattern</em>.</li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>'<strong>=CondPattern</strong>' (lexicographically
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe equal)<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe Treats the <em>CondPattern</em> as a plain string and
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe compares it lexicographically to <em>TestString</em>. True if
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em>TestString</em> is lexicographically equal to
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em>CondPattern</em> (the two strings are exactly
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe equal, character for character). If <em>CondPattern</em>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe is <code>""</code> (two quotation marks) this
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe compares <em>TestString</em> to the empty string.</li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>'<strong>-d</strong>' (is
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <strong>d</strong>irectory)<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe Treats the <em>TestString</em> as a pathname and tests
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe whether or not it exists, and is a directory.</li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>'<strong>-f</strong>' (is regular
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <strong>f</strong>ile)<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe Treats the <em>TestString</em> as a pathname and tests
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe whether or not it exists, and is a regular file.</li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>'<strong>-s</strong>' (is regular file, with
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <strong>s</strong>ize)<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe Treats the <em>TestString</em> as a pathname and tests
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe whether or not it exists, and is a regular file with size greater
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe than zero.</li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>'<strong>-l</strong>' (is symbolic
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <strong>l</strong>ink)<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe Treats the <em>TestString</em> as a pathname and tests
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe whether or not it exists, and is a symbolic link.</li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>'<strong>-x</strong>' (has e<strong>x</strong>ecutable
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe permissions)<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe Treats the <em>TestString</em> as a pathname and tests
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe whether or not it exists, and has executable permissions.
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe These permissions are determined according to
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe the underlying OS.</li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>'<strong>-F</strong>' (is existing file, via
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe subrequest)<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe Checks whether or not <em>TestString</em> is a valid file,
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe accessible via all the server's currently-configured
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe access controls for that path. This uses an internal
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe subrequest to do the check, so use it with care -
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe it can impact your server's performance!</li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>'<strong>-U</strong>' (is existing URL, via
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe subrequest)<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe Checks whether or not <em>TestString</em> is a valid URL,
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe accessible via all the server's currently-configured
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe access controls for that path. This uses an internal
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe subrequest to do the check, so use it with care -
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe it can impact your server's performance!</li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </ul>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="note"><h3>Note:</h3>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe All of these tests can
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe also be prefixed by an exclamation mark ('!') to
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe negate their meaning.
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>You can also set special flags for
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em>CondPattern</em> by appending
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <strong><code>[</code><em>flags</em><code>]</code></strong>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe as the third argument to the <code>RewriteCond</code>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe directive, where <em>flags</em> is a comma-separated list of any of the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe following flags:
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <ul>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>'<strong><code>nocase|NC</code></strong>'
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe (<strong>n</strong>o <strong>c</strong>ase)<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe This makes the test case-insensitive - differences
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe between 'A-Z' and 'a-z' are ignored, both in the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe expanded <em>TestString</em> and the <em>CondPattern</em>.
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe This flag is effective only for comparisons between
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em>TestString</em> and <em>CondPattern</em>. It has no
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe effect on filesystem and subrequest checks.</li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe '<strong><code>ornext|OR</code></strong>'
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe (<strong>or</strong> next condition)<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe Use this to combine rule conditions with a local OR
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe instead of the implicit AND. Typical example:
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="example"><pre>
ceaa05c302b4a0013174f4344c0907df84f7390dwroweRewriteCond %{REMOTE_HOST} ^host1.* [OR]
ceaa05c302b4a0013174f4344c0907df84f7390dwroweRewriteCond %{REMOTE_HOST} ^host2.* [OR]
ceaa05c302b4a0013174f4344c0907df84f7390dwroweRewriteCond %{REMOTE_HOST} ^host3.*
ceaa05c302b4a0013174f4344c0907df84f7390dwroweRewriteRule ...some special stuff for any of these hosts...
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</pre></div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe Without this flag you would have to write the condition/rule
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe pair three times.
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>'<strong><code>novary|NV</code></strong>'
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe (<strong>n</strong>o <strong>v</strong>ary)<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe If a HTTP header is used in the condition, this flag prevents
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe this header from being added to the Vary header of the response. <br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe Using this flag might break proper caching of the response if
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe the representation of this response varies on the value of this header.
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe So this flag should be only used if the meaning of the Vary header
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe is well understood.
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </ul>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </ol>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p><strong>Example:</strong></p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>To rewrite the Homepage of a site according to the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe ``<code>User-Agent:</code>'' header of the request, you can
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe use the following: </p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="example"><pre>
ceaa05c302b4a0013174f4344c0907df84f7390dwroweRewriteCond %{HTTP_USER_AGENT} ^Mozilla.*
ceaa05c302b4a0013174f4344c0907df84f7390dwroweRewriteRule ^/$ /homepage.max.html [L]
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwroweRewriteCond %{HTTP_USER_AGENT} ^Lynx.*
ceaa05c302b4a0013174f4344c0907df84f7390dwroweRewriteRule ^/$ /homepage.min.html [L]
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwroweRewriteRule ^/$ /homepage.std.html [L]
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</pre></div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>Explanation: If you use a browser which identifies itself
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe as 'Mozilla' (including Netscape Navigator, Mozilla etc), then you
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe get the max homepage (which could include frames, or other special
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe features).
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe If you use the Lynx browser (which is terminal-based), then
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe you get the min homepage (which could be a version designed for
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe easy, text-only browsing).
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe If neither of these conditions apply (you use any other browser,
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe or your browser identifies itself as something non-standard), you get
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe the std (standard) homepage.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="directive-section"><h2><a name="RewriteEngine" id="RewriteEngine">RewriteEngine</a> <a name="rewriteengine" id="rewriteengine">Directive</a></h2>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<table class="directive">
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Enables or disables runtime rewriting engine</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteEngine on|off</code></td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>RewriteEngine off</code></td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</table>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>The <code class="directive">RewriteEngine</code> directive enables or
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe disables the runtime rewriting engine. If it is set to
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>off</code> this module does no runtime processing at
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe all. It does not even update the <code>SCRIPT_URx</code>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe environment variables.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>Use this directive to disable the module instead of
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe commenting out all the <code class="directive"><a href="#rewriterule">RewriteRule</a></code> directives!</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>Note that rewrite configurations are not
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe inherited by virtual hosts. This means that you need to have a
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>RewriteEngine on</code> directive for each virtual host
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe in which you wish to use rewrite rules.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p><code class="directive">RewriteMap</code> directives of the type <code>prg</code>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe are not started during server initialization if they're defined in a
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe context that does not have <code class="directive">RewriteEngine</code> set to
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>on</code></p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="directive-section"><h2><a name="RewriteLog" id="RewriteLog">RewriteLog</a> <a name="rewritelog" id="rewritelog">Directive</a></h2>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<table class="directive">
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets the name of the file used for logging rewrite engine
ceaa05c302b4a0013174f4344c0907df84f7390dwroweprocessing</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteLog <em>file-path</em></code></td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</table>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>The <code class="directive">RewriteLog</code> directive sets the name
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe of the file to which the server logs any rewriting actions it
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe performs. If the name does not begin with a slash
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe ('<code>/</code>') then it is assumed to be relative to the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em>Server Root</em>. The directive should occur only once per
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe server config.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="note"> To disable the logging of
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe rewriting actions it is not recommended to set
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em>Filename</em> to <code>/dev/null</code>, because
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe although the rewriting engine does not then output to a
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe logfile it still creates the logfile output internally.
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <strong>This will slow down the server with no advantage
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe to the administrator!</strong> To disable logging either
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe remove or comment out the <code class="directive">RewriteLog</code>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe directive or use <code>RewriteLogLevel 0</code>!
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="note"><h3>Security</h3>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwroweSee the <a href="/misc/security_tips.html">Apache Security Tips</a>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowedocument for details on how your security could be compromised if the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowedirectory where logfiles are stored is writable by anyone other than
ceaa05c302b4a0013174f4344c0907df84f7390dwrowethe user that starts the server.
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="example"><h3>Example</h3><p><code>
ceaa05c302b4a0013174f4344c0907df84f7390dwroweRewriteLog "/usr/local/var/apache/logs/rewrite.log"
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</code></p></div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="directive-section"><h2><a name="RewriteLogLevel" id="RewriteLogLevel">RewriteLogLevel</a> <a name="rewriteloglevel" id="rewriteloglevel">Directive</a></h2>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<table class="directive">
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets the verbosity of the log file used by the rewrite
ceaa05c302b4a0013174f4344c0907df84f7390dwroweengine</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteLogLevel <em>Level</em></code></td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>RewriteLogLevel 0</code></td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</table>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>The <code class="directive">RewriteLogLevel</code> directive sets the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe verbosity level of the rewriting logfile. The default level 0
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe means no logging, while 9 or more means that practically all
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe actions are logged.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>To disable the logging of rewriting actions simply set
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em>Level</em> to 0. This disables all rewrite action
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe logs.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="note"> Using a high value for
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em>Level</em> will slow down your Apache server
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe dramatically! Use the rewriting logfile at a
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em>Level</em> greater than 2 only for debugging!
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="example"><h3>Example</h3><p><code>
ceaa05c302b4a0013174f4344c0907df84f7390dwroweRewriteLogLevel 3
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</code></p></div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="directive-section"><h2><a name="RewriteMap" id="RewriteMap">RewriteMap</a> <a name="rewritemap" id="rewritemap">Directive</a></h2>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<table class="directive">
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Defines a mapping function for key-lookup</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteMap <em>MapName</em> <em>MapType</em>:<em>MapSource</em>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</code></td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>The choice of different dbm types is available in
ceaa05c302b4a0013174f4344c0907df84f7390dwroweApache 2.0.41 and later</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</table>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>The <code class="directive">RewriteMap</code> directive defines a
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em>Rewriting Map</em> which can be used inside rule
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe substitution strings by the mapping-functions to
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe insert/substitute fields through a key lookup. The source of
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe this lookup can be of various types.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>The <a id="mapfunc" name="mapfunc"><em>MapName</em></a> is
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe the name of the map and will be used to specify a
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe mapping-function for the substitution strings of a rewriting
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe rule via one of the following constructs:</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p class="indent">
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <strong><code>${</code> <em>MapName</em> <code>:</code>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em>LookupKey</em> <code>}</code><br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>${</code> <em>MapName</em> <code>:</code>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em>LookupKey</em> <code>|</code> <em>DefaultValue</em>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>}</code></strong>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>When such a construct occurs, the map <em>MapName</em> is
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe consulted and the key <em>LookupKey</em> is looked-up. If the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe key is found, the map-function construct is substituted by
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em>SubstValue</em>. If the key is not found then it is
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe substituted by <em>DefaultValue</em> or by the empty string
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe if no <em>DefaultValue</em> was specified.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>For example, you might define a
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code class="directive">RewriteMap</code> as:</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <div class="example"><p><code>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe RewriteMap examplemap txt:/path/to/file/map.txt
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </code></p></div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>You would then be able to use this map in a
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code class="directive">RewriteRule</code> as follows:</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <div class="example"><p><code>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe RewriteRule ^/ex/(.*) ${examplemap:$1}
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </code></p></div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>The following combinations for <em>MapType</em> and
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em>MapSource</em> can be used:</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <ul>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <strong>Standard Plain Text</strong><br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe MapType: <code>txt</code>, MapSource: Unix filesystem
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe path to valid regular file
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>This is the standard rewriting map feature where the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em>MapSource</em> is a plain ASCII file containing
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe either blank lines, comment lines (starting with a '#'
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe character) or pairs like the following - one per
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe line.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p class="indent">
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <strong><em>MatchingKey</em>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em>SubstValue</em></strong>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="example"><h3>Example</h3><pre>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe##
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe## map.txt -- rewriting map
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe##
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwroweRalf.S.Engelschall rse # Bastard Operator From Hell
ceaa05c302b4a0013174f4344c0907df84f7390dwroweMr.Joe.Average joe # Mr. Average
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</pre></div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="example"><p><code>
ceaa05c302b4a0013174f4344c0907df84f7390dwroweRewriteMap real-to-user txt:/path/to/file/map.txt
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</code></p></div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <strong>Randomized Plain Text</strong><br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe MapType: <code>rnd</code>, MapSource: Unix filesystem
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe path to valid regular file
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>This is identical to the Standard Plain Text variant
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe above but with a special post-processing feature: After
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe looking up a value it is parsed according to contained
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe ``<code>|</code>'' characters which have the meaning of
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe ``or''. In other words they indicate a set of
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe alternatives from which the actual returned value is
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe chosen randomly. For example, you might use the following map
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe file and directives to provide a random load balancing between
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe several back-end server, via a reverse-proxy. Images are sent
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe to one of the servers in the 'static' pool, while everything
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe else is sent to one of the 'dynamic' pool.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>Example:</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="example"><h3>Rewrite map file</h3><pre>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe##
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe## map.txt -- rewriting map
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe##
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowestatic www1|www2|www3|www4
ceaa05c302b4a0013174f4344c0907df84f7390dwrowedynamic www5|www6
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</pre></div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="example"><h3>Configuration directives</h3><p><code>
ceaa05c302b4a0013174f4344c0907df84f7390dwroweRewriteMap servers rnd:/path/to/file/map.txt<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwroweRewriteRule ^/(.*\.(png|gif|jpg)) http://${servers:static}/$1
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe[NC,P,L]<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwroweRewriteRule ^/(.*) http://${servers:dynamic}/$1 [P,L]
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</code></p></div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <strong>Hash File</strong><br /> MapType:
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>dbm[=<em>type</em>]</code>, MapSource: Unix filesystem
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe path to valid regular file
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>Here the source is a binary format DBM file containing
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe the same contents as a <em>Plain Text</em> format file, but
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe in a special representation which is optimized for really
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe fast lookups. The <em>type</em> can be sdbm, gdbm, ndbm, or
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe db depending on <a href="/install.html#dbm">compile-time
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe settings</a>. If the <em>type</em> is omitted, the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe compile-time default will be chosen.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>To create a dbm file from a source text file, use the <a href="/programs/httxt2dbm.html">httxt2dbm</a> utility.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="example"><p><code>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe$ httxt2dbm -i mapfile.txt -o mapfile.map
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</code></p></div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <strong>Internal Function</strong><br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe MapType: <code>int</code>, MapSource: Internal Apache
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe function
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>Here, the source is an internal Apache function.
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe Currently you cannot create your own, but the following
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe functions already exist:</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <ul>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li><strong>toupper</strong>:<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe Converts the key to all upper case.</li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li><strong>tolower</strong>:<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe Converts the key to all lower case.</li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li><strong>escape</strong>:<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe Translates special characters in the key to
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe hex-encodings.</li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li><strong>unescape</strong>:<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe Translates hex-encodings in the key back to
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe special characters.</li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </ul>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <strong>External Rewriting Program</strong><br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe MapType: <code>prg</code>, MapSource: Unix filesystem
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe path to valid regular file
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>Here the source is a program, not a map file. To
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe create it you can use a language of your choice, but
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe the result has to be an executable program (either
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe object-code or a script with the magic cookie trick
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe '<code>#!/path/to/interpreter</code>' as the first
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe line).</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>This program is started once, when the Apache server
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe is started, and then communicates with the rewriting engine
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe via its <code>stdin</code> and <code>stdout</code>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe file-handles. For each map-function lookup it will
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe receive the key to lookup as a newline-terminated string
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe on <code>stdin</code>. It then has to give back the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe looked-up value as a newline-terminated string on
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>stdout</code> or the four-character string
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe ``<code>NULL</code>'' if it fails (<em>i.e.</em>, there
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe is no corresponding value for the given key).</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>This feature utilizes the <code>rewrite-map</code> mutex,
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe which is required for reliable communication with the program.
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe The mutex mechanism and lock file can be configured with the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code class="directive"><a href="/mod/core.html#mutex">Mutex</a></code> directive.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>External rewriting programs are not started if they're defined in a
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe context that does not have <code class="directive">RewriteEngine</code> set to
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>on</code></p>.
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>A trivial program which will implement a 1:1 map (<em>i.e.</em>,
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe key == value) could be:</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="example"><pre>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe#!/usr/bin/perl
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe$| = 1;
ceaa05c302b4a0013174f4344c0907df84f7390dwrowewhile (&lt;STDIN&gt;) {
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe # ...put here any transformations or lookups...
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe print $_;
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe}
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</pre></div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>But be very careful:</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <ol>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>``<em>Keep it simple, stupid</em>'' (KISS).
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe If this program hangs, it will cause Apache to hang
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe when trying to use the relevant rewrite rule.</li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>A common mistake is to use buffered I/O on
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>stdout</code>. Avoid this, as it will cause a deadloop!
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe ``<code>$|=1</code>'' is used above, to prevent this.</li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </ol>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p><strong>SQL Query</strong><br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe MapType: <code>dbd</code> or <code>fastdbd</code>,
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe MapSource: An SQL SELECT statement that takes a single
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe argument and returns a single value.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>This uses <code class="module"><a href="/mod/mod_dbd.html">mod_dbd</a></code> to implement a rewritemap
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe by lookup in an SQL database. There are two forms:
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>fastdbd</code> caches database lookups internally,
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>dbd</code> doesn't. So <code>dbd</code> incurs a
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe performance penalty but responds immediately if the database
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe contents are updated, while <code>fastdbd</code> is more
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe efficient but won't re-read database contents until server
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe restart.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>If a query returns more than one row, a random row from
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe the result set is used.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="example"><h3>Example</h3><p><code>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwroweRewriteMap myquery "fastdbd:SELECT destination FROM rewrite WHERE source = %s"
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</code></p></div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </ul>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>The <code class="directive">RewriteMap</code> directive can occur more than
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe once. For each mapping-function use one
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code class="directive">RewriteMap</code> directive to declare its rewriting
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe mapfile. While you cannot <strong>declare</strong> a map in
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe per-directory context it is of course possible to
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <strong>use</strong> this map in per-directory context. </p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="note"><h3>Note</h3> For plain text and DBM format files the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowelooked-up keys are cached in-core until the <code>mtime</code> of the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowemapfile changes or the server does a restart. This way you can have
ceaa05c302b4a0013174f4344c0907df84f7390dwrowemap-functions in rules which are used for <strong>every</strong>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowerequest. This is no problem, because the external lookup only happens
ceaa05c302b4a0013174f4344c0907df84f7390dwroweonce!
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="directive-section"><h2><a name="RewriteOptions" id="RewriteOptions">RewriteOptions</a> <a name="rewriteoptions" id="rewriteoptions">Directive</a></h2>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<table class="directive">
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets some special options for the rewrite engine</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteOptions <var>Options</var></code></td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td><code>MaxRedirects</code> is no longer available in version 2.1 and
ceaa05c302b4a0013174f4344c0907df84f7390dwrowelater</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</table>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>The <code class="directive">RewriteOptions</code> directive sets some
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe special options for the current per-server or per-directory
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe configuration. The <em>Option</em> string can currently
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe only be one of the following:</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <dl>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <dt><code>inherit</code></dt>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <dd>This forces the current configuration to inherit the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe configuration of the parent. In per-virtual-server context,
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe this means that the maps, conditions and rules of the main
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe server are inherited. In per-directory context this means
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe that conditions and rules of the parent directory's
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>.htaccess</code> configuration or
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code class="directive"><a href="/mod/core.html#directory">&lt;Directory&gt;</a></code>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe sections are inherited. The inherited rules are virtually copied
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe to the section where this directive is being used. If used in
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe combination with local rules, the inherited rules are copied behind
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe the local rules. The position of this directive - below or above
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe of local rules - has no influence on this behavior. If local
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe rules forced the rewriting to stop, the inherited rules won't
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe be processed.</dd>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </dl>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="directive-section"><h2><a name="RewriteRule" id="RewriteRule">RewriteRule</a> <a name="rewriterule" id="rewriterule">Directive</a></h2>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<table class="directive">
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Defines rules for the rewriting engine</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteRule
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em>Pattern</em> <em>Substitution</em> [<em>flags</em>]</code></td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</table>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>The <code class="directive">RewriteRule</code> directive is the real
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe rewriting workhorse. The directive can occur more than once,
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe with each instance defining a single rewrite rule. The
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe order in which these rules are defined is important - this is the order
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe in which they will be applied at run-time.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p><a id="patterns" name="patterns"><em>Pattern</em></a> is
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe a perl compatible <a id="regexp" name="regexp">regular
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe expression</a>. On the first RewriteRule it is applied to the (%-encoded)
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <a href="/directive-dict.html#Syntax">URL-path</a> of the request;
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe subsequent patterns are applied to the output of the last matched
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe RewriteRule.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="note"><h3>What is matched?</h3>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>The <em>Pattern</em> will initially be matched against the part of the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe URL after the hostname and port, and before the query string.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg <p>When the RewriteRule appears in per-directory (htaccess) context, the
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg <em>Pattern</em> is matched against what remains of the URL after removing
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg the prefix that lead Apache to the current rules (see the
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg <code class="directive"><a href="#rewritebase">RewriteBase</a></code>). The removed prefix
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg always ends with a slash, meaning the matching occurs against a string which
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg never has a leading slash. A <em>Pattern</em> with <code>^/</code> never
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg matches in per-directory context.</p>
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg <p>If you wish to match against the hostname, port, or query string, use a
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg <code class="directive"><a href="#rewritecond">RewriteCond</a></code> with the
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg <code>%{HTTP_HOST}</code>, <code>%{SERVER_PORT}</code>, or
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg <code>%{QUERY_STRING}</code> variables respectively. If you wish to
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg match against the full URL-path in a per-directory (htaccess) RewriteRule,
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg use the <code>%{REQUEST_URI}</code> variable.</p>
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg</div>
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg <p>For some hints on <a class="glossarylink" href="/glossary.html#regex" title="see glossary">regular
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg expressions</a>, see
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg the <a href="/rewrite/intro.html#regex">mod_rewrite
a985f6595e5da3e4b35bd91eab0a6eac3cbc8ae4fuankg Introduction</a>.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>In mod_rewrite, the NOT character
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe ('<code>!</code>') is also available as a possible pattern
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe prefix. This enables you to negate a pattern; to say, for instance:
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe ``<em>if the current URL does <strong>NOT</strong> match this
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe pattern</em>''. This can be used for exceptional cases, where
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe it is easier to match the negative pattern, or as a last
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe default rule.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="note"><h3>Note</h3>
ceaa05c302b4a0013174f4344c0907df84f7390dwroweWhen using the NOT character to negate a pattern, you cannot include
ceaa05c302b4a0013174f4344c0907df84f7390dwrowegrouped wildcard parts in that pattern. This is because, when the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowepattern does NOT match (ie, the negation matches), there are no
ceaa05c302b4a0013174f4344c0907df84f7390dwrowecontents for the groups. Thus, if negated patterns are used, you
ceaa05c302b4a0013174f4344c0907df84f7390dwrowecannot use <code>$N</code> in the substitution string!
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>The <a id="rhs" name="rhs"><em>Substitution</em></a> of a
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe rewrite rule is the string that replaces the original URL-path that
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe was matched by <em>Pattern</em>. The <em>Substitution</em> may
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe be a:</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <dl>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <dt>file-system path</dt>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <dd>Designates the location on the file-system of the resource
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe to be delivered to the client.</dd>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <dt>URL-path</dt>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <dd>A <code class="directive"><a href="/mod/core.html#documentroot">DocumentRoot</a></code>-relative path to the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe resource to be served. Note that <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe tries to guess whether you have specified a file-system path
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe or a URL-path by checking to see if the first segment of the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe path exists at the root of the file-system. For example, if
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe you specify a <em>Substitution</em> string of
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>/www/file.html</code>, then this will be treated as a
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe URL-path <em>unless</em> a directory named <code>www</code>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe exists at the root or your file-system, in which case it will
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe be treated as a file-system path. If you wish other
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe URL-mapping directives (such as <code class="directive"><a href="/mod/mod_alias.html#alias">Alias</a></code>) to be applied to the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe resulting URL-path, use the <code>[PT]</code> flag as
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe described below.</dd>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <dt>Absolute URL</dt>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <dd>If an absolute URL is specified,
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> checks to see whether the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe hostname matches the current host. If it does, the scheme and
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe hostname are stripped out and the resulting path is treated as
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe a URL-path. Otherwise, an external redirect is performed for
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe the given URL. To force an external redirect back to the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe current host, see the <code>[R]</code> flag below.</dd>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <dt><code>-</code> (dash)</dt>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <dd>A dash indicates that no substitution should be performed
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe (the existing path is passed through untouched). This is used
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe when a flag (see below) needs to be applied without changing
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe the path.</dd>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </dl>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>In addition to plain text, the <em>Substition</em> string can include</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <ol>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>back-references (<code>$N</code>) to the RewriteRule
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe pattern</li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>back-references (<code>%N</code>) to the last matched
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe RewriteCond pattern</li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li>server-variables as in rule condition test-strings
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe (<code>%{VARNAME}</code>)</li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <li><a href="#mapfunc">mapping-function</a> calls
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe (<code>${mapname:key|default}</code>)</li>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </ol>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>Back-references are identifiers of the form
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>$</code><strong>N</strong>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe (<strong>N</strong>=0..9), which will be replaced
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe by the contents of the <strong>N</strong>th group of the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe matched <em>Pattern</em>. The server-variables are the same
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe as for the <em>TestString</em> of a <code>RewriteCond</code>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe directive. The mapping-functions come from the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>RewriteMap</code> directive and are explained there.
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe These three types of variables are expanded in the order above.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>As already mentioned, all rewrite rules are
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe applied to the <em>Substitution</em> (in the order in which
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe they are defined
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe in the config file). The URL is <strong>completely
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe replaced</strong> by the <em>Substitution</em> and the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe rewriting process continues until all rules have been applied,
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe or it is explicitly terminated by a
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code><strong>L</strong></code> flag.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <div class="note"><h3>Modifying the Query String</h3>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>By default, the query string is passed through unchanged. You
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe can, however, create URLs in the substitution string containing
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe a query string part. Simply use a question mark inside the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe substitution string to indicate that the following text should
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe be re-injected into the query string. When you want to erase an
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe existing query string, end the substitution string with just a
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe question mark. To combine new and old query strings, use the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>[QSA]</code> flag.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>Additionally you can set special <a name="rewriteflags" id="rewriteflags">actions</a> to be performed by
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe appending <strong><code>[</code><em>flags</em><code>]</code></strong>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe as the third argument to the <code>RewriteRule</code>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe directive. <em>Flags</em> is a comma-separated list, surround by square
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe brackets, of any of the flags in the following table. More
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe details, and examples, for each flag, are available in the <a href="/rewrite/flags.html">Rewrite Flags document</a>.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <table>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <tr><th>Flag and syntax</th>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <th>Function</th>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>B</td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>Escape non-alphanumeric characters <em>before</em> applying
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe the transformation. <em><a href="/rewrite/flags.html#flag_b">details ...</a></em></td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>chain|C</td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>Rule is chained to the following rule. If the rule fails,
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe the rule(s) chained to it will be skipped. <em><a href="/rewrite/flags.html#flag_c">details ...</a></em></td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>cookie|CO=<em>NAME</em>:<em>VAL</em></td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>Sets a cookie in the client browser. Full syntax is:
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe 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>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>discardpathinfo|DPI</td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>Causes the PATH_INFO portion of the rewritten URI to be
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe discarded. <em><a href="/rewrite/flags.html#flag_dpi">details
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe ...</a></em></td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>env|E=<em>VAR</em>:<em>VAL</em></td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>Causes an environment variable <em>VAR</em> to be set to the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe value <em>VAL</em>. <em><a href="/rewrite/flags.html#flag_e">details ...</a></em></td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>forbidden|F</td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>Returns a 403 FORBIDDEN response to the client browser.
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em><a href="/rewrite/flags.html#flag_f">details ...</a></em></td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>gone|G</td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>Returns a 410 GONE response to the client browser. <em><a href="/rewrite/flags.html#flag_g">details ...</a></em></td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>Handler|H=<em>Content-handler</em></td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>Causes the resulting URI to be sent to the specified
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em>Content-handler</em> for processing. <em><a href="/rewrite/flags.html#flag_h">details ...</a></em></td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>last|L</td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>Stop the rewriting process immediately and don't apply any
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe more rules. Especially note caveats for per-directory and
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe .htaccess context. <em><a href="/rewrite/flags.html#flag_l">details ...</a></em></td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>next|N</td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>Re-run the rewriting process, starting again with the first
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe rule, using the result of the ruleset so far as a starting
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe point. <em><a href="/rewrite/flags.html#flag_n">details
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe ...</a></em></td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>nocase|NC</td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>Makes the pattern pattern comparison case-insensitive.
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em><a href="/rewrite/flags.html#flag_nc">details ...</a></em></td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>noescape|NE</td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>Prevent mod_rewrite from applying hexcode escaping of
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe special characters in the result of the rewrite. <em><a href="/rewrite/flags.html#flag_ne">details ...</a></em></td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>nosubreq|NS</td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>Causes a rule to be skipped if the current request is an
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe internal sub-request. <em><a href="/rewrite/flags.html#flag_ns">details ...</a></em></td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>proxy|P</td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>Force the substitution URL to be internally sent as a proxy
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe request. <em><a href="/rewrite/flags.html#flag_p">details
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe ...</a></em></td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>passthrough|PT</td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>Forces the resulting URI to be passed back to the URL
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe mapping engine for processing of other URI-to-filename
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe translators, such as <code>Alias</code> or
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>Redirect</code>. <em><a href="/rewrite/flags.html#flag_pt">details ...</a></em></td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>qsappend|QSA</td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>Appends any query string created in the rewrite target to
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe any query string that was in the original request URL. <em><a href="/rewrite/flags.html#flag_qsa">details ...</a></em></td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>qsdiscard|QSD</td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>Discard any query string attached to the incoming URI.
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <em><a href="/rewrite/flags.html#flag_qsd">details
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe ...</a></em></td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>redirect|R[=<em>code</em>]</td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>Forces an external redirect, optionally with the specified
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe HTTP status code. <em><a href="/rewrite/flags.html#flag_r">details ...</a></em>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>skip|S=<em>num</em></td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>Tells the rewriting engine to skip the next <em>num</em>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe rules if the current rule matches. <em><a href="/rewrite/flags.html#flag_s">details ...</a></em></td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>tyle|T=<em>MIME-type</em></td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <td>Force the <a class="glossarylink" href="/glossary.html#mime-type" title="see glossary">MIME-type</a> of the target file
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe to be the specified type. <em><a href="/rewrite/flags.html#flag_t">details ...</a></em></td>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </tr>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </table>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="note"><h3>Home directory expansion</h3>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<p> When the substitution string begins with a string
ceaa05c302b4a0013174f4344c0907df84f7390dwroweresembling "/~user" (via explicit text or backreferences), mod_rewrite performs
ceaa05c302b4a0013174f4344c0907df84f7390dwrowehome directory expansion independent of the presence or configuration
ceaa05c302b4a0013174f4344c0907df84f7390dwroweof <code class="module"><a href="/mod/mod_userdir.html">mod_userdir</a></code>.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<p> This expansion does not occur when the <em>PT</em>
ceaa05c302b4a0013174f4344c0907df84f7390dwroweflag is used on the <code class="directive"><a href="#rewriterule">RewriteRule</a></code>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowedirective.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="note"><h3>Per-directory Rewrites</h3>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<p>The rewrite engine may be used in <a href="/howto/htaccess.html">.htaccess</a> files. To enable the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowerewrite engine for these files you need to set
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe"<code>RewriteEngine On</code>" <strong>and</strong>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe"<code>Options FollowSymLinks</code>" must be enabled. If your
ceaa05c302b4a0013174f4344c0907df84f7390dwroweadministrator has disabled override of <code>FollowSymLinks</code> for
ceaa05c302b4a0013174f4344c0907df84f7390dwrowea user's directory, then you cannot use the rewrite engine. This
ceaa05c302b4a0013174f4344c0907df84f7390dwrowerestriction is required for security reasons.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<p>When using the rewrite engine in <code>.htaccess</code> files the
ceaa05c302b4a0013174f4344c0907df84f7390dwroweper-directory prefix (which always is the same for a specific
ceaa05c302b4a0013174f4344c0907df84f7390dwrowedirectory) is automatically <em>removed</em> for the pattern matching
ceaa05c302b4a0013174f4344c0907df84f7390dwroweand automatically <em>added</em> after the substitution has been
ceaa05c302b4a0013174f4344c0907df84f7390dwrowedone. This feature is essential for many sorts of rewriting; without
ceaa05c302b4a0013174f4344c0907df84f7390dwrowethis, you would always have to match the parent directory, which is
ceaa05c302b4a0013174f4344c0907df84f7390dwrowenot always possible. There is one exception: If a substitution string
ceaa05c302b4a0013174f4344c0907df84f7390dwrowestarts with <code>http://</code>, then the directory prefix will
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<strong>not</strong> be added, and an external redirect (or proxy
ceaa05c302b4a0013174f4344c0907df84f7390dwrowethroughput, if using flag <strong>P</strong>) is forced. See the
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<code class="directive"><a href="#rewritebase">RewriteBase</a></code> directive for
ceaa05c302b4a0013174f4344c0907df84f7390dwrowemore information.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<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
ceaa05c302b4a0013174f4344c0907df84f7390dwroweprefix-matching rules as would be applied to <code>.htaccess</code>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowefiles. It is usually simpler, however, to avoid the prefix substitution
ceaa05c302b4a0013174f4344c0907df84f7390dwrowecomplication by putting the rewrite rules in the main server or
ceaa05c302b4a0013174f4344c0907df84f7390dwrowevirtual host context, rather than in a <code class="directive"><a href="/mod/core.html#directory">&lt;Directory&gt;</a></code> section.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<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
ceaa05c302b4a0013174f4344c0907df84f7390dwroweshould never be necessary and is unsupported.</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p>Here are all possible substitution combinations and their
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe meanings:</p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p><strong>Inside per-server configuration
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe (<code>httpd.conf</code>)<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe for request ``<code>GET
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe /somepath/pathinfo</code>'':</strong><br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="note"><pre>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<strong>Given Rule</strong> <strong>Resulting Substitution</strong>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe---------------------------------------------- ----------------------------------
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe^/somepath(.*) otherpath$1 invalid, not supported
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe^/somepath(.*) otherpath$1 [R] invalid, not supported
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe^/somepath(.*) otherpath$1 [P] invalid, not supported
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe---------------------------------------------- ----------------------------------
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe^/somepath(.*) /otherpath$1 /otherpath/pathinfo
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe^/somepath(.*) /otherpath$1 [R] http://thishost/otherpath/pathinfo
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe via external redirection
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe^/somepath(.*) /otherpath$1 [P] doesn't make sense, not supported
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe---------------------------------------------- ----------------------------------
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe^/somepath(.*) http://thishost/otherpath$1 /otherpath/pathinfo
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe^/somepath(.*) http://thishost/otherpath$1 [R] http://thishost/otherpath/pathinfo
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe via external redirection
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe^/somepath(.*) http://thishost/otherpath$1 [P] doesn't make sense, not supported
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe---------------------------------------------- ----------------------------------
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe^/somepath(.*) http://otherhost/otherpath$1 http://otherhost/otherpath/pathinfo
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe via external redirection
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe^/somepath(.*) http://otherhost/otherpath$1 [R] http://otherhost/otherpath/pathinfo
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe via external redirection
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe (the [R] flag is redundant)
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe^/somepath(.*) http://otherhost/otherpath$1 [P] http://otherhost/otherpath/pathinfo
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe via internal proxy
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</pre></div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <p><strong>Inside per-directory configuration for
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>/somepath</code><br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe (<code>/physical/path/to/somepath/.htacccess</code>, with
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe <code>RewriteBase /somepath</code>)<br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe for request ``<code>GET
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe /somepath/localpath/pathinfo</code>'':</strong><br />
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe </p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="note"><pre>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<strong>Given Rule</strong> <strong>Resulting Substitution</strong>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe---------------------------------------------- ----------------------------------
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe^localpath(.*) otherpath$1 /somepath/otherpath/pathinfo
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe^localpath(.*) otherpath$1 [R] http://thishost/somepath/otherpath/pathinfo
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe via external redirection
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe^localpath(.*) otherpath$1 [P] doesn't make sense, not supported
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe---------------------------------------------- ----------------------------------
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe^localpath(.*) /otherpath$1 /otherpath/pathinfo
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe^localpath(.*) /otherpath$1 [R] http://thishost/otherpath/pathinfo
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe via external redirection
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe^localpath(.*) /otherpath$1 [P] doesn't make sense, not supported
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe---------------------------------------------- ----------------------------------
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe^localpath(.*) http://thishost/otherpath$1 /otherpath/pathinfo
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe^localpath(.*) http://thishost/otherpath$1 [R] http://thishost/otherpath/pathinfo
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe via external redirection
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe^localpath(.*) http://thishost/otherpath$1 [P] doesn't make sense, not supported
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe---------------------------------------------- ----------------------------------
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe^localpath(.*) http://otherhost/otherpath$1 http://otherhost/otherpath/pathinfo
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe via external redirection
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe^localpath(.*) http://otherhost/otherpath$1 [R] http://otherhost/otherpath/pathinfo
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe via external redirection
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe (the [R] flag is redundant)
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe^localpath(.*) http://otherhost/otherpath$1 [P] http://otherhost/otherpath/pathinfo
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe via internal proxy
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</pre></div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</div>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<div class="bottomlang">
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<p><span>Available Languages: </span><a href="/en/mod/mod_rewrite.html" title="English">&nbsp;en&nbsp;</a> |
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<a href="/fr/mod/mod_rewrite.html" hreflang="fr" rel="alternate" title="Fran�ais">&nbsp;fr&nbsp;</a></p>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</div><div id="footer">
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<p class="apache">Copyright 2010 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>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe<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>
ceaa05c302b4a0013174f4344c0907df84f7390dwrowe</body></html>