mod_rewrite.html.en revision f736cd11585a35572d5f42accf026eb667848434
97a9a944b5887e91042b019776c41d5dd74557aferikabele<?xml version="1.0" encoding="ISO-8859-1"?>
97a9a944b5887e91042b019776c41d5dd74557aferikabele<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
97a9a944b5887e91042b019776c41d5dd74557aferikabele<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
b1ced323143ade589985456a78f3f64d6a6580c5yoshiki XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
b1ced323143ade589985456a78f3f64d6a6580c5yoshiki This file is generated from xml source: DO NOT EDIT
b1ced323143ade589985456a78f3f64d6a6580c5yoshiki XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd -->
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<title>mod_rewrite - Apache HTTP Server</title>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<link href="/images/favicon.ico" rel="shortcut icon" /></head>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<body>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div id="page-header">
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="/faq/">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p>
52fff662005b1866a3ff09bb6c902800c5cc6dedjerenkrantz<p class="apache">Apache HTTP Server Version 2.3</p>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<img alt="" src="/images/feather.gif" /></div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="/images/left.gif" /></a></div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div id="path">
4b5981e276e93df97c34e4da05ca5cf8bbd937dand<a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="../">Version 2.3</a> &gt; <a href="./">Modules</a></div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div id="page-content">
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div id="preamble"><h1>Apache Module mod_rewrite</h1>
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd<div class="toplang">
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd<p><span>Available Languages: </span><a href="/en/mod/mod_rewrite.html" title="English">&nbsp;en&nbsp;</a></p>
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd</div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Provides a rule-based rewriting engine to rewrite requested
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4ndURLs on the fly</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="module-dict.html#Status">Status:</a></th><td>Extension</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="module-dict.html#ModuleIdentifier">Module�Identifier:</a></th><td>rewrite_module</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="module-dict.html#SourceFile">Source�File:</a></th><td>mod_rewrite.c</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="module-dict.html#Compatibility">Compatibility:</a></th><td>Available in Apache 1.3 and later</td></tr></table>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<h3>Summary</h3>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>This module uses a rule-based rewriting engine (based on a
06ba4a61654b3763ad65f52283832ebf058fdf1cslive regular-expression parser) to rewrite requested URLs on the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive fly. It supports an unlimited number of rules and an
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem unlimited number of attached rule conditions for each rule, to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive provide a really flexible and powerful URL manipulation
06ba4a61654b3763ad65f52283832ebf058fdf1cslive mechanism. The URL manipulations can depend on various tests,
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem of server variables, environment variables, HTTP
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem headers, or time stamps. Even external database lookups in
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem various formats can be used to achieve highly granular URL
06ba4a61654b3763ad65f52283832ebf058fdf1cslive matching.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>This module operates on the full URLs (including the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive path-info part) both in per-server context
06ba4a61654b3763ad65f52283832ebf058fdf1cslive (<code>httpd.conf</code>) and per-directory context
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem (<code>.htaccess</code>) and can generate query-string
06ba4a61654b3763ad65f52283832ebf058fdf1cslive parts on result. The rewritten result can lead to internal
06ba4a61654b3763ad65f52283832ebf058fdf1cslive sub-processing, external request redirection or even to an
06ba4a61654b3763ad65f52283832ebf058fdf1cslive internal proxy throughput.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen <p>Further details, discussion, and examples, are provided in the
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen <a href="/rewrite/">detailed mod_rewrite documentation</a>.</p>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div id="quickview"><h3 class="directives">Directives</h3>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<ul id="toc">
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<li><img alt="" src="/images/down.gif" /> <a href="#rewritebase">RewriteBase</a></li>
117c1f888a14e73cdd821dc6c23eb0411144a41cnd<li><img alt="" src="/images/down.gif" /> <a href="#rewritecond">RewriteCond</a></li>
117c1f888a14e73cdd821dc6c23eb0411144a41cnd<li><img alt="" src="/images/down.gif" /> <a href="#rewriteengine">RewriteEngine</a></li>
117c1f888a14e73cdd821dc6c23eb0411144a41cnd<li><img alt="" src="/images/down.gif" /> <a href="#rewritelock">RewriteLock</a></li>
117c1f888a14e73cdd821dc6c23eb0411144a41cnd<li><img alt="" src="/images/down.gif" /> <a href="#rewritelog">RewriteLog</a></li>
117c1f888a14e73cdd821dc6c23eb0411144a41cnd<li><img alt="" src="/images/down.gif" /> <a href="#rewriteloglevel">RewriteLogLevel</a></li>
117c1f888a14e73cdd821dc6c23eb0411144a41cnd<li><img alt="" src="/images/down.gif" /> <a href="#rewritemap">RewriteMap</a></li>
117c1f888a14e73cdd821dc6c23eb0411144a41cnd<li><img alt="" src="/images/down.gif" /> <a href="#rewriteoptions">RewriteOptions</a></li>
117c1f888a14e73cdd821dc6c23eb0411144a41cnd<li><img alt="" src="/images/down.gif" /> <a href="#rewriterule">RewriteRule</a></li>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</ul>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<h3>Topics</h3>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<ul id="topics">
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen<li><img alt="" src="/images/down.gif" /> <a href="#quoting">Quoting Special Characters</a></li>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<li><img alt="" src="/images/down.gif" /> <a href="#EnvVar">Environment Variables</a></li>
4c36c711036219c80d5517d35be68a4769c15291slive<li><img alt="" src="/images/down.gif" /> <a href="#vhosts">Rewriting in Virtual Hosts</a></li>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<li><img alt="" src="/images/down.gif" /> <a href="#Solutions">Practical Solutions</a></li>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</ul></div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="section">
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen<h2><a name="quoting" id="quoting">Quoting Special Characters</a></h2>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>As of Apache 1.3.20, special characters in
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>TestString</em> and <em>Substitution</em> strings can be
06ba4a61654b3763ad65f52283832ebf058fdf1cslive escaped (that is, treated as normal characters without their
b95ae799514ad86a15610ad75808d7065e9847c9kess usual special meaning) by prefixing them with a slash ('\')
06ba4a61654b3763ad65f52283832ebf058fdf1cslive character. In other words, you can include an actual
06ba4a61654b3763ad65f52283832ebf058fdf1cslive dollar-sign character in a <em>Substitution</em> string by
06ba4a61654b3763ad65f52283832ebf058fdf1cslive using '<code>\$</code>'; this keeps mod_rewrite from trying
06ba4a61654b3763ad65f52283832ebf058fdf1cslive to treat it as a backreference.</p>
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen<div class="section">
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<h2><a name="EnvVar" id="EnvVar">Environment Variables</a></h2>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>This module keeps track of two additional (non-standard)
06ba4a61654b3763ad65f52283832ebf058fdf1cslive CGI/SSI environment variables named <code>SCRIPT_URL</code>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive and <code>SCRIPT_URI</code>. These contain the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>logical</em> Web-view to the current resource, while the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive standard CGI/SSI variables <code>SCRIPT_NAME</code> and
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>SCRIPT_FILENAME</code> contain the <em>physical</em>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive System-view. </p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>Notice: These variables hold the URI/URL <em>as they were
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem initially requested</em>, that is, <em>before</em> any
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem rewriting. This is important to note because the rewriting process is
06ba4a61654b3763ad65f52283832ebf058fdf1cslive primarily used to rewrite logical URLs to physical
06ba4a61654b3763ad65f52283832ebf058fdf1cslive pathnames.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele<div class="example"><h3>Example</h3><pre>
06ba4a61654b3763ad65f52283832ebf058fdf1csliveSCRIPT_NAME=/sw/lib/w3s/tree/global/u/rse/.www/index.html
06ba4a61654b3763ad65f52283832ebf058fdf1csliveSCRIPT_FILENAME=/u/rse/.www/index.html
06ba4a61654b3763ad65f52283832ebf058fdf1csliveSCRIPT_URL=/u/rse/
06ba4a61654b3763ad65f52283832ebf058fdf1csliveSCRIPT_URI=http://en1.engelschall.com/u/rse/
97a9a944b5887e91042b019776c41d5dd74557aferikabele</pre></div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
4c36c711036219c80d5517d35be68a4769c15291slive</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
4c36c711036219c80d5517d35be68a4769c15291slive<div class="section">
4c36c711036219c80d5517d35be68a4769c15291slive<h2><a name="vhosts" id="vhosts">Rewriting in Virtual Hosts</a></h2>
4c36c711036219c80d5517d35be68a4769c15291slive
4c36c711036219c80d5517d35be68a4769c15291slive <p>By default, <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> configuration
4c36c711036219c80d5517d35be68a4769c15291slive settings from the main server context are not inherited by
4c36c711036219c80d5517d35be68a4769c15291slive virtual hosts. To make the main server settings apply to virtual
4c36c711036219c80d5517d35be68a4769c15291slive hosts, you must place the following directives in each <code class="directive"><a href="/mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code> section:</p>
4c36c711036219c80d5517d35be68a4769c15291slive
4c36c711036219c80d5517d35be68a4769c15291slive <div class="example"><p><code>
4c36c711036219c80d5517d35be68a4769c15291slive RewriteEngine On<br />
f736cd11585a35572d5f42accf026eb667848434slive RewriteOptions Inherit
4c36c711036219c80d5517d35be68a4769c15291slive </code></p></div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="section">
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<h2><a name="Solutions" id="Solutions">Practical Solutions</a></h2>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen <p>For numerous examples of common, and not-so-common, uses for
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen mod_rewrite, see the <a href="/rewrite/rewrite_guide.html">Rewrite
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen Guide</a>, and the <a href="/rewrite/rewrite_guide_advanced.html">Advanced Rewrite
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen Guide</a> documents.</p>
f0a393c5c2d7de58f447855369ad2fbfa254e544rbowen
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="directive-section"><h2><a name="RewriteBase" id="RewriteBase">RewriteBase</a> <a name="rewritebase" id="rewritebase">Directive</a></h2>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<table class="directive">
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets the base URL for per-directory rewrites</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteBase <em>URL-path</em></code></td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>See usage for information.</code></td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>directory, .htaccess</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</table>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>The <code class="directive">RewriteBase</code> directive explicitly
06ba4a61654b3763ad65f52283832ebf058fdf1cslive sets the base URL for per-directory rewrites. As you will see
97a9a944b5887e91042b019776c41d5dd74557aferikabele below, <code class="directive"><a href="#rewriterule">RewriteRule</a></code>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive can be used in per-directory config files
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem (<code>.htaccess</code>). In such a case, it will act locally,
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem stripping the local directory prefix before processing, and applying
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem rewrite rules only to the remainder. When processing is complete, the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem prefix is automatically added back to the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive path. The default setting is; <code class="directive">RewriteBase</code> <em>physical-directory-path</em></p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>When a substitution occurs for a new URL, this module has
06ba4a61654b3763ad65f52283832ebf058fdf1cslive to re-inject the URL into the server processing. To be able
06ba4a61654b3763ad65f52283832ebf058fdf1cslive to do this it needs to know what the corresponding URL-prefix
06ba4a61654b3763ad65f52283832ebf058fdf1cslive or URL-base is. By default this prefix is the corresponding
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem filepath itself. <strong>However, for most websites, URLs are NOT
06ba4a61654b3763ad65f52283832ebf058fdf1cslive directly related to physical filename paths, so this
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem assumption will often be wrong!</strong> Therefore, you can
06ba4a61654b3763ad65f52283832ebf058fdf1cslive use the <code>RewriteBase</code> directive to specify the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive correct URL-prefix.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele<div class="note"> If your webserver's URLs are <strong>not</strong> directly
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluemrelated to physical file paths, you will need to use
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<code class="directive">RewriteBase</code> in every <code>.htaccess</code>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluemfile where you want to use <code class="directive"><a href="#rewriterule">RewriteRule</a></code> directives.
97a9a944b5887e91042b019776c41d5dd74557aferikabele</div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p> For example, assume the following per-directory config file:</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele<div class="example"><pre>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive#
06ba4a61654b3763ad65f52283832ebf058fdf1cslive# /abc/def/.htaccess -- per-dir config file for directory /abc/def
06ba4a61654b3763ad65f52283832ebf058fdf1cslive# Remember: /abc/def is the physical path of /xyz, <em>i.e.</em>, the server
06ba4a61654b3763ad65f52283832ebf058fdf1cslive# has a 'Alias /xyz /abc/def' directive <em>e.g.</em>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive#
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1csliveRewriteEngine On
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive# let the server know that we were reached via /xyz and not
06ba4a61654b3763ad65f52283832ebf058fdf1cslive# via the physical path prefix /abc/def
06ba4a61654b3763ad65f52283832ebf058fdf1csliveRewriteBase /xyz
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive# now the rewriting rules
06ba4a61654b3763ad65f52283832ebf058fdf1csliveRewriteRule ^oldstuff\.html$ newstuff.html
97a9a944b5887e91042b019776c41d5dd74557aferikabele</pre></div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>In the above example, a request to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>/xyz/oldstuff.html</code> gets correctly rewritten to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the physical file <code>/abc/def/newstuff.html</code>.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele<div class="note"><h3>For Apache Hackers</h3>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<p>The following list gives detailed information about
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the internal processing steps:</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<pre>
06ba4a61654b3763ad65f52283832ebf058fdf1csliveRequest:
06ba4a61654b3763ad65f52283832ebf058fdf1cslive /xyz/oldstuff.html
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1csliveInternal Processing:
06ba4a61654b3763ad65f52283832ebf058fdf1cslive /xyz/oldstuff.html -&gt; /abc/def/oldstuff.html (per-server Alias)
06ba4a61654b3763ad65f52283832ebf058fdf1cslive /abc/def/oldstuff.html -&gt; /abc/def/newstuff.html (per-dir RewriteRule)
06ba4a61654b3763ad65f52283832ebf058fdf1cslive /abc/def/newstuff.html -&gt; /xyz/newstuff.html (per-dir RewriteBase)
06ba4a61654b3763ad65f52283832ebf058fdf1cslive /xyz/newstuff.html -&gt; /abc/def/newstuff.html (per-server Alias)
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1csliveResult:
06ba4a61654b3763ad65f52283832ebf058fdf1cslive /abc/def/newstuff.html
06ba4a61654b3763ad65f52283832ebf058fdf1cslive</pre>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p>This seems very complicated, but is in fact
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem correct Apache internal processing. Because the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem per-directory rewriting comes late in the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem process, the rewritten request
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem has to be re-injected into the Apache kernel.
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem This is not the serious overhead it may seem to be -
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem this re-injection is completely internal to the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Apache server (and the same procedure is used by
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem many other operations within Apache).</p>
97a9a944b5887e91042b019776c41d5dd74557aferikabele</div>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="directive-section"><h2><a name="RewriteCond" id="RewriteCond">RewriteCond</a> <a name="rewritecond" id="rewritecond">Directive</a></h2>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<table class="directive">
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Defines a condition under which rewriting will take place
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code> RewriteCond
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <em>TestString</em> <em>CondPattern</em></code></td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</table>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>The <code class="directive">RewriteCond</code> directive defines a
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem rule condition. One or more <code class="directive">RewriteCond</code>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem can precede a <code class="directive"><a href="#rewriterule">RewriteRule</a></code>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem directive. The following rule is then only used if both
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem the current state of the URI matches its pattern, <strong>and</strong> if these conditions are met.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p><em>TestString</em> is a string which can contain the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive following expanded constructs in addition to plain text:</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <ul>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong>RewriteRule backreferences</strong>: These are
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem backreferences of the form <strong><code>$N</code></strong>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem (0 &lt;= N &lt;= 9), which provide access to the grouped
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem parts (in parentheses) of the pattern, from the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>RewriteRule</code> which is subject to the current
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem set of <code>RewriteCond</code> conditions..
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong>RewriteCond backreferences</strong>: These are
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem backreferences of the form <strong><code>%N</code></strong>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem (1 &lt;= N &lt;= 9), which provide access to the grouped
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem parts (again, in parentheses) of the pattern, from the last matched
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>RewriteCond</code> in the current set
06ba4a61654b3763ad65f52283832ebf058fdf1cslive of conditions.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong>RewriteMap expansions</strong>: These are
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem expansions of the form <strong><code>${mapname:key|default}</code></strong>.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive See <a href="#mapfunc">the documentation for
06ba4a61654b3763ad65f52283832ebf058fdf1cslive RewriteMap</a> for more details.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong>Server-Variables</strong>: These are variables of
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the form
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong><code>%{</code> <em>NAME_OF_VARIABLE</em>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>}</code></strong>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive where <em>NAME_OF_VARIABLE</em> can be a string taken
06ba4a61654b3763ad65f52283832ebf058fdf1cslive from the following list:
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele <table>
c6a2d6fa44f8698851dec5051ee3782c2913605fnd
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <tr>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <th>HTTP headers:</th> <th>connection &amp; request:</th> <th />
97a9a944b5887e91042b019776c41d5dd74557aferikabele </tr>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
97a9a944b5887e91042b019776c41d5dd74557aferikabele <tr>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <td>
97a9a944b5887e91042b019776c41d5dd74557aferikabele HTTP_USER_AGENT<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele HTTP_REFERER<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele HTTP_COOKIE<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele HTTP_FORWARDED<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele HTTP_HOST<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele HTTP_PROXY_CONNECTION<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele HTTP_ACCEPT<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <td>
97a9a944b5887e91042b019776c41d5dd74557aferikabele REMOTE_ADDR<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele REMOTE_HOST<br />
74a6de79356cd15d2e47065087785e36dd65aa41nd REMOTE_PORT<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele REMOTE_USER<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele REMOTE_IDENT<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele REQUEST_METHOD<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele SCRIPT_FILENAME<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele PATH_INFO<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele QUERY_STRING<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele AUTH_TYPE<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </td>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
97a9a944b5887e91042b019776c41d5dd74557aferikabele <td />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <tr>
53d2fd50ff45e7c568f0588c742a5ef9edf8e275rbowen <th>server internals:</th> <th>date and time:</th> <th>specials:</th>
97a9a944b5887e91042b019776c41d5dd74557aferikabele </tr>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
97a9a944b5887e91042b019776c41d5dd74557aferikabele <tr>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <td>
97a9a944b5887e91042b019776c41d5dd74557aferikabele DOCUMENT_ROOT<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele SERVER_ADMIN<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele SERVER_NAME<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele SERVER_ADDR<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele SERVER_PORT<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele SERVER_PROTOCOL<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele SERVER_SOFTWARE<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <td>
97a9a944b5887e91042b019776c41d5dd74557aferikabele TIME_YEAR<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele TIME_MON<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele TIME_DAY<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele TIME_HOUR<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele TIME_MIN<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele TIME_SEC<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele TIME_WDAY<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele TIME<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <td>
97a9a944b5887e91042b019776c41d5dd74557aferikabele API_VERSION<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele THE_REQUEST<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele REQUEST_URI<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele REQUEST_FILENAME<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele IS_SUBREQ<br />
fb82af0f0cd7b58eef19c54b086131b7e1e1e749madhum HTTPS<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </td>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </tr>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </table>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>These variables all
06ba4a61654b3763ad65f52283832ebf058fdf1cslive correspond to the similarly named HTTP
06ba4a61654b3763ad65f52283832ebf058fdf1cslive MIME-headers, C variables of the Apache server or
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>struct tm</code> fields of the Unix system.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive Most are documented elsewhere in the Manual or in
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the CGI specification. Those that are special to
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem mod_rewrite include those below.</p>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <div class="note">
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dl>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dt><code>IS_SUBREQ</code></dt>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dd>Will contain the text "true" if the request
06ba4a61654b3763ad65f52283832ebf058fdf1cslive currently being processed is a sub-request,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive "false" otherwise. Sub-requests may be generated
06ba4a61654b3763ad65f52283832ebf058fdf1cslive by modules that need to resolve additional files
06ba4a61654b3763ad65f52283832ebf058fdf1cslive or URIs in order to complete their tasks.</dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dt><code>API_VERSION</code></dt>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dd>This is the version of the Apache module API
06ba4a61654b3763ad65f52283832ebf058fdf1cslive (the internal interface between server and
06ba4a61654b3763ad65f52283832ebf058fdf1cslive module) in the current httpd build, as defined in
06ba4a61654b3763ad65f52283832ebf058fdf1cslive include/ap_mmn.h. The module API version
06ba4a61654b3763ad65f52283832ebf058fdf1cslive corresponds to the version of Apache in use (in
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the release version of Apache 1.3.14, for
06ba4a61654b3763ad65f52283832ebf058fdf1cslive instance, it is 19990320:10), but is mainly of
06ba4a61654b3763ad65f52283832ebf058fdf1cslive interest to module authors.</dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dt><code>THE_REQUEST</code></dt>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dd>The full HTTP request line sent by the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive browser to the server (e.g., "<code>GET
06ba4a61654b3763ad65f52283832ebf058fdf1cslive /index.html HTTP/1.1</code>"). This does not
06ba4a61654b3763ad65f52283832ebf058fdf1cslive include any additional headers sent by the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive browser.</dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dt><code>REQUEST_URI</code></dt>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dd>The resource requested in the HTTP request
06ba4a61654b3763ad65f52283832ebf058fdf1cslive line. (In the example above, this would be
06ba4a61654b3763ad65f52283832ebf058fdf1cslive "/index.html".)</dd>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dt><code>REQUEST_FILENAME</code></dt>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <dd>The full local filesystem path to the file or
06ba4a61654b3763ad65f52283832ebf058fdf1cslive script matching the request.</dd>
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd <dt><code>HTTPS</code></dt>
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd <dd>Will contain the text "on" if the connection is
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd using SSL/TLS, or "off" otherwise. (This variable
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem can be safely used regardless of whether or not
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd <code class="module"><a href="/mod/mod_ssl.html">mod_ssl</a></code> is loaded).</dd>
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </dl>
97a9a944b5887e91042b019776c41d5dd74557aferikabele</div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </ul>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p>Other things you should be aware of:</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <ol>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>The variables SCRIPT_FILENAME and REQUEST_FILENAME
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem contain the same value - the value of the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>filename</code> field of the internal
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>request_rec</code> structure of the Apache server.
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem The first name is the commonly known CGI variable name
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem while the second is the appropriate counterpart of
06ba4a61654b3763ad65f52283832ebf058fdf1cslive REQUEST_URI (which contains the value of the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>uri</code> field of <code>request_rec</code>).</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>%{ENV:variable}</code>, where <em>variable</em> can be
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem any environment variable, is also available.
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem This is looked-up via internal
06ba4a61654b3763ad65f52283832ebf058fdf1cslive Apache structures and (if not found there) via
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>getenv()</code> from the Apache server process.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>%{SSL:variable}</code>, where <em>variable</em> is the
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd name of an <a href="mod_ssl.html#envvars">SSL environment
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem variable</a>, can be used whether or not
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd <code class="module"><a href="/mod/mod_ssl.html">mod_ssl</a></code> is loaded, but will always expand to
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd the empty string if it is not. Example:
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd <code>%{SSL:SSL_CIPHER_USEKEYSIZE}</code> may expand to
eaaa852423e42d6d86bcada80ed781a205fc3e5fnd <code>128</code>.</li>
fb82af0f0cd7b58eef19c54b086131b7e1e1e749madhum
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>%{HTTP:header}</code>, where <em>header</em> can be
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem any HTTP MIME-header name, can always be used to obtain the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem value of a header sent in the HTTP request.
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Example: <code>%{HTTP:Proxy-Connection}</code> is
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the value of the HTTP header
06ba4a61654b3763ad65f52283832ebf058fdf1cslive ``<code>Proxy-Connection:</code>''.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>%{LA-U:variable}</code> can be used for look-aheads which perform
06ba4a61654b3763ad65f52283832ebf058fdf1cslive an internal (URL-based) sub-request to determine the final
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem value of <em>variable</em>. This can be used to access
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem variable for rewriting which is not available at the current
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem stage, but will be set in a later phase.
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p>For instance, to rewrite according to the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>REMOTE_USER</code> variable from within the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem per-server context (<code>httpd.conf</code> file) you must
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem use <code>%{LA-U:REMOTE_USER}</code> - this
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem variable is set by the authorization phases, which come
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <em>after</em> the URL translation phase (during which mod_rewrite
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem operates).</p>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p>On the other hand, because mod_rewrite implements
06ba4a61654b3763ad65f52283832ebf058fdf1cslive its per-directory context (<code>.htaccess</code> file) via
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the Fixup phase of the API and because the authorization
06ba4a61654b3763ad65f52283832ebf058fdf1cslive phases come <em>before</em> this phase, you just can use
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>%{REMOTE_USER}</code> in that context.</p></li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>%{LA-F:variable}</code> can be used to perform an internal
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem (filename-based) sub-request, to determine the final value
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem of <em>variable</em>. Most of the time, this is the same as
06ba4a61654b3763ad65f52283832ebf058fdf1cslive LA-U above.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </ol>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p><em>CondPattern</em> is the condition pattern,
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem a regular expression which is applied to the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem current instance of the <em>TestString</em>.
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <em>TestString</em> is first evaluated, before being matched against
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>CondPattern</em>.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p><strong>Remember:</strong> <em>CondPattern</em> is a
630c456b6461158be6cc5c5483735e27b13b4ad5nd <em>perl compatible regular expression</em> with some
06ba4a61654b3763ad65f52283832ebf058fdf1cslive additions:</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <ol>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>You can prefix the pattern string with a
06ba4a61654b3763ad65f52283832ebf058fdf1cslive '<code>!</code>' character (exclamation mark) to specify a
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong>non</strong>-matching pattern.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive There are some special variants of <em>CondPatterns</em>.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive Instead of real regular expression strings you can also
06ba4a61654b3763ad65f52283832ebf058fdf1cslive use one of the following:
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <ul>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>'<strong>&lt;CondPattern</strong>' (lexicographically
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem precedes)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Treats the <em>CondPattern</em> as a plain string and
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem compares it lexicographically to <em>TestString</em>. True if
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <em>TestString</em> lexicographically precedes
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>CondPattern</em>.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>'<strong>&gt;CondPattern</strong>' (lexicographically
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem follows)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Treats the <em>CondPattern</em> as a plain string and
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem compares it lexicographically to <em>TestString</em>. True if
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <em>TestString</em> lexicographically follows
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>CondPattern</em>.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>'<strong>=CondPattern</strong>' (lexicographically
97a9a944b5887e91042b019776c41d5dd74557aferikabele equal)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Treats the <em>CondPattern</em> as a plain string and
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem compares it lexicographically to <em>TestString</em>. True if
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <em>TestString</em> is lexicographically equal to
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <em>CondPattern</em> (the two strings are exactly
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem equal, character for character). If <em>CondPattern</em>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem is <code>""</code> (two quotation marks) this
06ba4a61654b3763ad65f52283832ebf058fdf1cslive compares <em>TestString</em> to the empty string.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>'<strong>-d</strong>' (is
97a9a944b5887e91042b019776c41d5dd74557aferikabele <strong>d</strong>irectory)<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive Treats the <em>TestString</em> as a pathname and tests
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem whether or not it exists, and is a directory.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>'<strong>-f</strong>' (is regular
97a9a944b5887e91042b019776c41d5dd74557aferikabele <strong>f</strong>ile)<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive Treats the <em>TestString</em> as a pathname and tests
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem whether or not it exists, and is a regular file.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>'<strong>-s</strong>' (is regular file, with
97a9a944b5887e91042b019776c41d5dd74557aferikabele <strong>s</strong>ize)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Treats the <em>TestString</em> as a pathname and tests
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem whether or not it exists, and is a regular file with size greater
06ba4a61654b3763ad65f52283832ebf058fdf1cslive than zero.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>'<strong>-l</strong>' (is symbolic
97a9a944b5887e91042b019776c41d5dd74557aferikabele <strong>l</strong>ink)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Treats the <em>TestString</em> as a pathname and tests
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem whether or not it exists, and is a symbolic link.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
4e3cdb85620921a8a120fe22edbccae708f4f34end <li>'<strong>-x</strong>' (has e<strong>x</strong>ecutable
4e3cdb85620921a8a120fe22edbccae708f4f34end permissions)<br />
4e3cdb85620921a8a120fe22edbccae708f4f34end Treats the <em>TestString</em> as a pathname and tests
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem whether or not it exists, and has executable permissions.
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem These permissions are determined according to
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem the underlying OS.</li>
4e3cdb85620921a8a120fe22edbccae708f4f34end
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>'<strong>-F</strong>' (is existing file, via
97a9a944b5887e91042b019776c41d5dd74557aferikabele subrequest)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Checks whether or not <em>TestString</em> is a valid file,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive accessible via all the server's currently-configured
06ba4a61654b3763ad65f52283832ebf058fdf1cslive access controls for that path. This uses an internal
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem subrequest to do the check, so use it with care -
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem it can impact your server's performance!</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>'<strong>-U</strong>' (is existing URL, via
97a9a944b5887e91042b019776c41d5dd74557aferikabele subrequest)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Checks whether or not <em>TestString</em> is a valid URL,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive accessible via all the server's currently-configured
06ba4a61654b3763ad65f52283832ebf058fdf1cslive access controls for that path. This uses an internal
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem subrequest to do the check, so use it with care -
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem it can impact your server's performance!</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </ul>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<div class="note"><h3>Note:</h3>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive All of these tests can
06ba4a61654b3763ad65f52283832ebf058fdf1cslive also be prefixed by an exclamation mark ('!') to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive negate their meaning.
97a9a944b5887e91042b019776c41d5dd74557aferikabele</div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>You can also set special flags for
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <em>CondPattern</em> by appending
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong><code>[</code><em>flags</em><code>]</code></strong>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem as the third argument to the <code>RewriteCond</code>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem directive, where <em>flags</em> is a comma-separated list of any of the
22d5d84393d960a2027f472036f3fee15d7dbce9nd following flags:
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <ul>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>'<strong><code>nocase|NC</code></strong>'
97a9a944b5887e91042b019776c41d5dd74557aferikabele (<strong>n</strong>o <strong>c</strong>ase)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem This makes the test case-insensitive - differences
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem between 'A-Z' and 'a-z' are ignored, both in the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive expanded <em>TestString</em> and the <em>CondPattern</em>.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive This flag is effective only for comparisons between
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>TestString</em> and <em>CondPattern</em>. It has no
06ba4a61654b3763ad65f52283832ebf058fdf1cslive effect on filesystem and subrequest checks.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive '<strong><code>ornext|OR</code></strong>'
97a9a944b5887e91042b019776c41d5dd74557aferikabele (<strong>or</strong> next condition)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Use this to combine rule conditions with a local OR
06ba4a61654b3763ad65f52283832ebf058fdf1cslive instead of the implicit AND. Typical example:
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele<div class="example"><pre>
06ba4a61654b3763ad65f52283832ebf058fdf1csliveRewriteCond %{REMOTE_HOST} ^host1.* [OR]
06ba4a61654b3763ad65f52283832ebf058fdf1csliveRewriteCond %{REMOTE_HOST} ^host2.* [OR]
06ba4a61654b3763ad65f52283832ebf058fdf1csliveRewriteCond %{REMOTE_HOST} ^host3.*
06ba4a61654b3763ad65f52283832ebf058fdf1csliveRewriteRule ...some special stuff for any of these hosts...
97a9a944b5887e91042b019776c41d5dd74557aferikabele</pre></div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Without this flag you would have to write the condition/rule
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem pair three times.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </ul>
22d5d84393d960a2027f472036f3fee15d7dbce9nd </li>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem </ol>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p><strong>Example:</strong></p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>To rewrite the Homepage of a site according to the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive ``<code>User-Agent:</code>'' header of the request, you can
06ba4a61654b3763ad65f52283832ebf058fdf1cslive use the following: </p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele<div class="example"><pre>
06ba4a61654b3763ad65f52283832ebf058fdf1csliveRewriteCond %{HTTP_USER_AGENT} ^Mozilla.*
06ba4a61654b3763ad65f52283832ebf058fdf1csliveRewriteRule ^/$ /homepage.max.html [L]
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1csliveRewriteCond %{HTTP_USER_AGENT} ^Lynx.*
06ba4a61654b3763ad65f52283832ebf058fdf1csliveRewriteRule ^/$ /homepage.min.html [L]
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1csliveRewriteRule ^/$ /homepage.std.html [L]
97a9a944b5887e91042b019776c41d5dd74557aferikabele</pre></div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p>Explanation: If you use a browser which identifies itself
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem as 'Mozilla' (including Netscape Navigator, Mozilla etc), then you
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem get the max homepage (which could include frames, or other special
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem features).
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem If you use the Lynx browser (which is terminal-based), then
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem you get the min homepage (which could be a version designed for
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem easy, text-only browsing).
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem If neither of these conditions apply (you use any other browser,
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem or your browser identifies itself as something non-standard), you get
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem the std (standard) homepage.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="directive-section"><h2><a name="RewriteEngine" id="RewriteEngine">RewriteEngine</a> <a name="rewriteengine" id="rewriteengine">Directive</a></h2>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<table class="directive">
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Enables or disables runtime rewriting engine</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteEngine on|off</code></td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>RewriteEngine off</code></td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</table>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>The <code class="directive">RewriteEngine</code> directive enables or
06ba4a61654b3763ad65f52283832ebf058fdf1cslive disables the runtime rewriting engine. If it is set to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>off</code> this module does no runtime processing at
06ba4a61654b3763ad65f52283832ebf058fdf1cslive all. It does not even update the <code>SCRIPT_URx</code>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive environment variables.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>Use this directive to disable the module instead of
97a9a944b5887e91042b019776c41d5dd74557aferikabele commenting out all the <code class="directive"><a href="#rewriterule">RewriteRule</a></code> directives!</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
4c36c711036219c80d5517d35be68a4769c15291slive <p>Note that rewrite configurations are not
4c36c711036219c80d5517d35be68a4769c15291slive inherited by virtual hosts. This means that you need to have a
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>RewriteEngine on</code> directive for each virtual host
4c36c711036219c80d5517d35be68a4769c15291slive in which you wish to use rewrite rules.</p>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="directive-section"><h2><a name="RewriteLock" id="RewriteLock">RewriteLock</a> <a name="rewritelock" id="rewritelock">Directive</a></h2>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<table class="directive">
627c978514c54179736d152923478be7c8707f9bnd<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets the name of the lock file used for <code class="directive"><a href="#rewritemap">RewriteMap</a></code>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4ndsynchronization</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteLock <em>file-path</em></code></td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</table>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>This directive sets the filename for a synchronization
97a9a944b5887e91042b019776c41d5dd74557aferikabele lockfile which mod_rewrite needs to communicate with <code class="directive"><a href="#rewritemap">RewriteMap</a></code>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>programs</em>. Set this lockfile to a local path (not on a
06ba4a61654b3763ad65f52283832ebf058fdf1cslive NFS-mounted device) when you want to use a rewriting
06ba4a61654b3763ad65f52283832ebf058fdf1cslive map-program. It is not required for other types of rewriting
06ba4a61654b3763ad65f52283832ebf058fdf1cslive maps.</p>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="directive-section"><h2><a name="RewriteLog" id="RewriteLog">RewriteLog</a> <a name="rewritelog" id="rewritelog">Directive</a></h2>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<table class="directive">
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets the name of the file used for logging rewrite engine
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4ndprocessing</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteLog <em>file-path</em></code></td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</table>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>The <code class="directive">RewriteLog</code> directive sets the name
06ba4a61654b3763ad65f52283832ebf058fdf1cslive of the file to which the server logs any rewriting actions it
06ba4a61654b3763ad65f52283832ebf058fdf1cslive performs. If the name does not begin with a slash
06ba4a61654b3763ad65f52283832ebf058fdf1cslive ('<code>/</code>') then it is assumed to be relative to the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>Server Root</em>. The directive should occur only once per
06ba4a61654b3763ad65f52283832ebf058fdf1cslive server config.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele<div class="note"> To disable the logging of
06ba4a61654b3763ad65f52283832ebf058fdf1cslive rewriting actions it is not recommended to set
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>Filename</em> to <code>/dev/null</code>, because
06ba4a61654b3763ad65f52283832ebf058fdf1cslive although the rewriting engine does not then output to a
06ba4a61654b3763ad65f52283832ebf058fdf1cslive logfile it still creates the logfile output internally.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong>This will slow down the server with no advantage
06ba4a61654b3763ad65f52283832ebf058fdf1cslive to the administrator!</strong> To disable logging either
06ba4a61654b3763ad65f52283832ebf058fdf1cslive remove or comment out the <code class="directive">RewriteLog</code>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive directive or use <code>RewriteLogLevel 0</code>!
97a9a944b5887e91042b019776c41d5dd74557aferikabele</div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele<div class="note"><h3>Security</h3>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1csliveSee the <a href="/misc/security_tips.html">Apache Security Tips</a>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluemdocument for details on how your security could be compromised if the
06ba4a61654b3763ad65f52283832ebf058fdf1cslivedirectory where logfiles are stored is writable by anyone other than
06ba4a61654b3763ad65f52283832ebf058fdf1cslivethe user that starts the server.
97a9a944b5887e91042b019776c41d5dd74557aferikabele</div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele<div class="example"><h3>Example</h3><p><code>
06ba4a61654b3763ad65f52283832ebf058fdf1csliveRewriteLog "/usr/local/var/apache/logs/rewrite.log"
97a9a944b5887e91042b019776c41d5dd74557aferikabele</code></p></div>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="directive-section"><h2><a name="RewriteLogLevel" id="RewriteLogLevel">RewriteLogLevel</a> <a name="rewriteloglevel" id="rewriteloglevel">Directive</a></h2>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<table class="directive">
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets the verbosity of the log file used by the rewrite
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4ndengine</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteLogLevel <em>Level</em></code></td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>RewriteLogLevel 0</code></td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</table>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>The <code class="directive">RewriteLogLevel</code> directive sets the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive verbosity level of the rewriting logfile. The default level 0
06ba4a61654b3763ad65f52283832ebf058fdf1cslive means no logging, while 9 or more means that practically all
06ba4a61654b3763ad65f52283832ebf058fdf1cslive actions are logged.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>To disable the logging of rewriting actions simply set
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>Level</em> to 0. This disables all rewrite action
06ba4a61654b3763ad65f52283832ebf058fdf1cslive logs.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele<div class="note"> Using a high value for
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>Level</em> will slow down your Apache server
06ba4a61654b3763ad65f52283832ebf058fdf1cslive dramatically! Use the rewriting logfile at a
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>Level</em> greater than 2 only for debugging!
97a9a944b5887e91042b019776c41d5dd74557aferikabele</div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele<div class="example"><h3>Example</h3><p><code>
06ba4a61654b3763ad65f52283832ebf058fdf1csliveRewriteLogLevel 3
97a9a944b5887e91042b019776c41d5dd74557aferikabele</code></p></div>
97a9a944b5887e91042b019776c41d5dd74557aferikabele
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="directive-section"><h2><a name="RewriteMap" id="RewriteMap">RewriteMap</a> <a name="rewritemap" id="rewritemap">Directive</a></h2>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<table class="directive">
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Defines a mapping function for key-lookup</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteMap <em>MapName</em> <em>MapType</em>:<em>MapSource</em>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</code></td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>The choice of different dbm types is available in
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4ndApache 2.0.41 and later</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</table>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>The <code class="directive">RewriteMap</code> directive defines a
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>Rewriting Map</em> which can be used inside rule
06ba4a61654b3763ad65f52283832ebf058fdf1cslive substitution strings by the mapping-functions to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive insert/substitute fields through a key lookup. The source of
06ba4a61654b3763ad65f52283832ebf058fdf1cslive this lookup can be of various types.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>The <a id="mapfunc" name="mapfunc"><em>MapName</em></a> is
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the name of the map and will be used to specify a
06ba4a61654b3763ad65f52283832ebf058fdf1cslive mapping-function for the substitution strings of a rewriting
06ba4a61654b3763ad65f52283832ebf058fdf1cslive rule via one of the following constructs:</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele <p class="indent">
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong><code>${</code> <em>MapName</em> <code>:</code>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <em>LookupKey</em> <code>}</code><br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>${</code> <em>MapName</em> <code>:</code>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>LookupKey</em> <code>|</code> <em>DefaultValue</em>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>}</code></strong>
97a9a944b5887e91042b019776c41d5dd74557aferikabele </p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p>When such a construct occurs, the map <em>MapName</em> is
06ba4a61654b3763ad65f52283832ebf058fdf1cslive consulted and the key <em>LookupKey</em> is looked-up. If the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive key is found, the map-function construct is substituted by
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>SubstValue</em>. If the key is not found then it is
06ba4a61654b3763ad65f52283832ebf058fdf1cslive substituted by <em>DefaultValue</em> or by the empty string
06ba4a61654b3763ad65f52283832ebf058fdf1cslive if no <em>DefaultValue</em> was specified.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen <p>For example, you might define a
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen <code class="directive">RewriteMap</code> as:</p>
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen <div class="example"><p><code>
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen RewriteMap examplemap txt:/path/to/file/map.txt
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen </code></p></div>
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen <p>You would then be able to use this map in a
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen <code class="directive">RewriteRule</code> as follows:</p>
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen <div class="example"><p><code>
8ac3ff7008df949c096f9cd8f769c7893594f61fnd RewriteRule ^/ex/(.*) ${examplemap:$1}
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen </code></p></div>
0ccb6ee166750359937ae35d59c0beb54f8fd228rbowen
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>The following combinations for <em>MapType</em> and
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>MapSource</em> can be used:</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <ul>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <strong>Standard Plain Text</strong><br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive MapType: <code>txt</code>, MapSource: Unix filesystem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive path to valid regular file
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>This is the standard rewriting map feature where the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>MapSource</em> is a plain ASCII file containing
06ba4a61654b3763ad65f52283832ebf058fdf1cslive either blank lines, comment lines (starting with a '#'
06ba4a61654b3763ad65f52283832ebf058fdf1cslive character) or pairs like the following - one per
06ba4a61654b3763ad65f52283832ebf058fdf1cslive line.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele <p class="indent">
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong><em>MatchingKey</em>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <em>SubstValue</em></strong>
97a9a944b5887e91042b019776c41d5dd74557aferikabele </p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele<div class="example"><h3>Example</h3><pre>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive##
06ba4a61654b3763ad65f52283832ebf058fdf1cslive## map.txt -- rewriting map
06ba4a61654b3763ad65f52283832ebf058fdf1cslive##
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1csliveRalf.S.Engelschall rse # Bastard Operator From Hell
06ba4a61654b3763ad65f52283832ebf058fdf1csliveMr.Joe.Average joe # Mr. Average
97a9a944b5887e91042b019776c41d5dd74557aferikabele</pre></div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele<div class="example"><p><code>
06ba4a61654b3763ad65f52283832ebf058fdf1csliveRewriteMap real-to-user txt:/path/to/file/map.txt
97a9a944b5887e91042b019776c41d5dd74557aferikabele</code></p></div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <strong>Randomized Plain Text</strong><br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive MapType: <code>rnd</code>, MapSource: Unix filesystem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive path to valid regular file
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>This is identical to the Standard Plain Text variant
06ba4a61654b3763ad65f52283832ebf058fdf1cslive above but with a special post-processing feature: After
06ba4a61654b3763ad65f52283832ebf058fdf1cslive looking up a value it is parsed according to contained
06ba4a61654b3763ad65f52283832ebf058fdf1cslive ``<code>|</code>'' characters which have the meaning of
06ba4a61654b3763ad65f52283832ebf058fdf1cslive ``or''. In other words they indicate a set of
06ba4a61654b3763ad65f52283832ebf058fdf1cslive alternatives from which the actual returned value is
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen chosen randomly. For example, you might use the following map
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen file and directives to provide a random load balancing between
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen several back-end server, via a reverse-proxy. Images are sent
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen to one of the servers in the 'static' pool, while everything
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen else is sent to one of the 'dynamic' pool.</p>
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen <p>Example:</p>
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen<div class="example"><h3>Rewrite map file</h3><pre>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive##
06ba4a61654b3763ad65f52283832ebf058fdf1cslive## map.txt -- rewriting map
06ba4a61654b3763ad65f52283832ebf058fdf1cslive##
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslivestatic www1|www2|www3|www4
06ba4a61654b3763ad65f52283832ebf058fdf1cslivedynamic www5|www6
97a9a944b5887e91042b019776c41d5dd74557aferikabele</pre></div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen<div class="example"><h3>Configuration directives</h3><p><code>
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowenRewriteMap servers rnd:/path/to/file/map.txt<br />
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen<br />
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowenRewriteRule ^/(.*\.(png|gif|jpg)) http://${servers:static}/$1
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowen[NC,P,L]<br />
36088d24dae5b2cc8124264fc6a9ba349ba81adcrbowenRewriteRule ^/(.*) http://${servers:dynamic}/$1 [P,L]
97a9a944b5887e91042b019776c41d5dd74557aferikabele</code></p></div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <strong>Hash File</strong><br /> MapType:
1578daeec017d3bb20cecdcdc3b0261c999730d5slive <code>dbm[=<em>type</em>]</code>, MapSource: Unix filesystem
1578daeec017d3bb20cecdcdc3b0261c999730d5slive path to valid regular file
1578daeec017d3bb20cecdcdc3b0261c999730d5slive
1578daeec017d3bb20cecdcdc3b0261c999730d5slive <p>Here the source is a binary format DBM file containing
1578daeec017d3bb20cecdcdc3b0261c999730d5slive the same contents as a <em>Plain Text</em> format file, but
1578daeec017d3bb20cecdcdc3b0261c999730d5slive in a special representation which is optimized for really
1578daeec017d3bb20cecdcdc3b0261c999730d5slive fast lookups. The <em>type</em> can be sdbm, gdbm, ndbm, or
1578daeec017d3bb20cecdcdc3b0261c999730d5slive db depending on <a href="/install.html#dbm">compile-time
ab6f5669a4cb16dbff7d791d434ba1b9c9b50928nd settings</a>. If the <em>type</em> is omitted, the
1578daeec017d3bb20cecdcdc3b0261c999730d5slive compile-time default will be chosen. You can create such a
1578daeec017d3bb20cecdcdc3b0261c999730d5slive file with any DBM tool or with the following Perl
1578daeec017d3bb20cecdcdc3b0261c999730d5slive script. Be sure to adjust it to create the appropriate
1578daeec017d3bb20cecdcdc3b0261c999730d5slive type of DBM. The example creates an NDBM file.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele<div class="example"><pre>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive#!/path/to/bin/perl
06ba4a61654b3763ad65f52283832ebf058fdf1cslive##
06ba4a61654b3763ad65f52283832ebf058fdf1cslive## txt2dbm -- convert txt map to dbm format
06ba4a61654b3763ad65f52283832ebf058fdf1cslive##
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1csliveuse NDBM_File;
06ba4a61654b3763ad65f52283832ebf058fdf1csliveuse Fcntl;
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive($txtmap, $dbmmap) = @ARGV;
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1csliveopen(TXT, "&lt;$txtmap") or die "Couldn't open $txtmap!\n";
97a9a944b5887e91042b019776c41d5dd74557aferikabeletie (%DB, 'NDBM_File', $dbmmap,O_RDWR|O_TRUNC|O_CREAT, 0644)
97a9a944b5887e91042b019776c41d5dd74557aferikabele or die "Couldn't create $dbmmap!\n";
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslivewhile (&lt;TXT&gt;) {
06ba4a61654b3763ad65f52283832ebf058fdf1cslive next if (/^\s*#/ or /^\s*$/);
06ba4a61654b3763ad65f52283832ebf058fdf1cslive $DB{$1} = $2 if (/^\s*(\S+)\s+(\S+)/);
06ba4a61654b3763ad65f52283832ebf058fdf1cslive}
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1csliveuntie %DB;
06ba4a61654b3763ad65f52283832ebf058fdf1csliveclose(TXT);
97a9a944b5887e91042b019776c41d5dd74557aferikabele</pre></div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele<div class="example"><p><code>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive$ txt2dbm map.txt map.db
97a9a944b5887e91042b019776c41d5dd74557aferikabele</code></p></div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <strong>Internal Function</strong><br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive MapType: <code>int</code>, MapSource: Internal Apache
06ba4a61654b3763ad65f52283832ebf058fdf1cslive function
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p>Here, the source is an internal Apache function.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive Currently you cannot create your own, but the following
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem functions already exist:</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <ul>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <li><strong>toupper</strong>:<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Converts the key to all upper case.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele <li><strong>tolower</strong>:<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Converts the key to all lower case.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele <li><strong>escape</strong>:<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Translates special characters in the key to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive hex-encodings.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele <li><strong>unescape</strong>:<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Translates hex-encodings in the key back to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive special characters.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </ul>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
97a9a944b5887e91042b019776c41d5dd74557aferikabele <strong>External Rewriting Program</strong><br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive MapType: <code>prg</code>, MapSource: Unix filesystem
06ba4a61654b3763ad65f52283832ebf058fdf1cslive path to valid regular file
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>Here the source is a program, not a map file. To
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem create it you can use a language of your choice, but
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem the result has to be an executable program (either
06ba4a61654b3763ad65f52283832ebf058fdf1cslive object-code or a script with the magic cookie trick
06ba4a61654b3763ad65f52283832ebf058fdf1cslive '<code>#!/path/to/interpreter</code>' as the first
06ba4a61654b3763ad65f52283832ebf058fdf1cslive line).</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p>This program is started once, when the Apache server
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem is started, and then communicates with the rewriting engine
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem via its <code>stdin</code> and <code>stdout</code>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive file-handles. For each map-function lookup it will
06ba4a61654b3763ad65f52283832ebf058fdf1cslive receive the key to lookup as a newline-terminated string
06ba4a61654b3763ad65f52283832ebf058fdf1cslive on <code>stdin</code>. It then has to give back the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive looked-up value as a newline-terminated string on
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>stdout</code> or the four-character string
06ba4a61654b3763ad65f52283832ebf058fdf1cslive ``<code>NULL</code>'' if it fails (<em>i.e.</em>, there
06ba4a61654b3763ad65f52283832ebf058fdf1cslive is no corresponding value for the given key). A trivial
06ba4a61654b3763ad65f52283832ebf058fdf1cslive program which will implement a 1:1 map (<em>i.e.</em>,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive key == value) could be:</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele<div class="example"><pre>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive#!/usr/bin/perl
06ba4a61654b3763ad65f52283832ebf058fdf1cslive$| = 1;
06ba4a61654b3763ad65f52283832ebf058fdf1cslivewhile (&lt;STDIN&gt;) {
06ba4a61654b3763ad65f52283832ebf058fdf1cslive # ...put here any transformations or lookups...
06ba4a61654b3763ad65f52283832ebf058fdf1cslive print $_;
06ba4a61654b3763ad65f52283832ebf058fdf1cslive}
97a9a944b5887e91042b019776c41d5dd74557aferikabele</pre></div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>But be very careful:</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <ol>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>``<em>Keep it simple, stupid</em>'' (KISS).
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem If this program hangs, it will cause Apache to hang
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem when trying to use the relevant rewrite rule.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>A common mistake is to use buffered I/O on
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>stdout</code>. Avoid this, as it will cause a deadloop!
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem ``<code>$|=1</code>'' is used above, to prevent this.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>The <code class="directive"><a href="#rewritelock">RewriteLock</a></code> directive can
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem be used to define a lockfile which mod_rewrite can use to synchronize
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem communication with the mapping program. By default no such
06ba4a61654b3763ad65f52283832ebf058fdf1cslive synchronization takes place.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </ol>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </li>
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd <li>
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd <p><strong>SQL Query</strong><br />
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd MapType: <code>dbd</code> or <code>fastdbd</code>,
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd MapSource: An SQL SELECT statement that takes a single
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd argument and returns a single value.</p>
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd <p>This uses <code class="module"><a href="/mod/mod_dbd.html">mod_dbd</a></code> to implement a rewritemap
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd by lookup in an SQL database. There are two forms:
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd <code>fastdbd</code> caches database lookups internally,
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd <code>dbd</code> doesn't. So <code>dbd</code> incurs a
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd performance penalty but responds immediately if the database
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd contents are updated, while <code>fastdbd</code> is more
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd efficient but won't re-read database contents until server
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd restart.</p>
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd <p>If a query returns more than one row, a random row from
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd the result set is used.</p>
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd<div class="example"><h3>Example</h3><p><code>
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisdRewriteMap myquery "fastdbd:SELECT destination FROM rewrite WHERE source = %s"
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd</code></p></div>
4c881d2fffa365e2e0c5e25eb1cf77f4f9406e44chrisd </li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </ul>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>The <code class="directive">RewriteMap</code> directive can occur more than
06ba4a61654b3763ad65f52283832ebf058fdf1cslive once. For each mapping-function use one
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code class="directive">RewriteMap</code> directive to declare its rewriting
06ba4a61654b3763ad65f52283832ebf058fdf1cslive mapfile. While you cannot <strong>declare</strong> a map in
06ba4a61654b3763ad65f52283832ebf058fdf1cslive per-directory context it is of course possible to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong>use</strong> this map in per-directory context. </p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele<div class="note"><h3>Note</h3> For plain text and DBM format files the
06ba4a61654b3763ad65f52283832ebf058fdf1cslivelooked-up keys are cached in-core until the <code>mtime</code> of the
06ba4a61654b3763ad65f52283832ebf058fdf1cslivemapfile changes or the server does a restart. This way you can have
06ba4a61654b3763ad65f52283832ebf058fdf1cslivemap-functions in rules which are used for <strong>every</strong>
06ba4a61654b3763ad65f52283832ebf058fdf1csliverequest. This is no problem, because the external lookup only happens
06ba4a61654b3763ad65f52283832ebf058fdf1csliveonce!
97a9a944b5887e91042b019776c41d5dd74557aferikabele</div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="directive-section"><h2><a name="RewriteOptions" id="RewriteOptions">RewriteOptions</a> <a name="rewriteoptions" id="rewriteoptions">Directive</a></h2>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<table class="directive">
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets some special options for the rewrite engine</td></tr>
0203b896e484dfb877111aceffb812401d0f216and<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteOptions <var>Options</var></code></td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
844def494f17cb1ab0983427d5c3939e1a03ff8cnd<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td><code>MaxRedirects</code> is no longer available in version 2.1 and
0203b896e484dfb877111aceffb812401d0f216andlater</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</table>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>The <code class="directive">RewriteOptions</code> directive sets some
06ba4a61654b3763ad65f52283832ebf058fdf1cslive special options for the current per-server or per-directory
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem configuration. The <em>Option</em> string can currently
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem only be one of the following:</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
0203b896e484dfb877111aceffb812401d0f216and <dl>
0203b896e484dfb877111aceffb812401d0f216and <dt><code>inherit</code></dt>
0203b896e484dfb877111aceffb812401d0f216and <dd>This forces the current configuration to inherit the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem configuration of the parent. In per-virtual-server context,
0203b896e484dfb877111aceffb812401d0f216and this means that the maps, conditions and rules of the main
0203b896e484dfb877111aceffb812401d0f216and server are inherited. In per-directory context this means
0203b896e484dfb877111aceffb812401d0f216and that conditions and rules of the parent directory's
0203b896e484dfb877111aceffb812401d0f216and <code>.htaccess</code> configuration are inherited.</dd>
0203b896e484dfb877111aceffb812401d0f216and </dl>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<div class="directive-section"><h2><a name="RewriteRule" id="RewriteRule">RewriteRule</a> <a name="rewriterule" id="rewriterule">Directive</a></h2>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<table class="directive">
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Defines rules for the rewriting engine</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteRule
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <em>Pattern</em> <em>Substitution</em></code></td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>The cookie-flag is available in Apache 2.0.40 and later.</td></tr>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</table>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>The <code class="directive">RewriteRule</code> directive is the real
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem rewriting workhorse. The directive can occur more than once,
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem with each instance defining a single rewrite rule. The
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem order in which these rules are defined is important - this is the order
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem in which they will be applied at run-time.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
630c456b6461158be6cc5c5483735e27b13b4ad5nd <p><a id="patterns" name="patterns"><em>Pattern</em></a> is
630c456b6461158be6cc5c5483735e27b13b4ad5nd a perl compatible <a id="regexp" name="regexp">regular
8c8c2e71c84babf0e8c4b35819c7c5b3be014cfenoodl expression</a>. On the first RewriteRule it is applied to the
8c8c2e71c84babf0e8c4b35819c7c5b3be014cfenoodl <a href="/directive-dict.html#Syntax">URL-path</a> of the request;
8c8c2e71c84babf0e8c4b35819c7c5b3be014cfenoodl subsequent patterns are applied to the output of the last matched
8c8c2e71c84babf0e8c4b35819c7c5b3be014cfenoodl RewriteRule.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p>Some hints on the syntax of <a class="glossarylink" href="/glossary.html#regex" title="see glossary">regular
d1348237b33bc1755b9f1165eea52317465a7671nd expressions</a>:</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele<div class="note"><pre>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<strong>Text:</strong>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong><code>.</code></strong> Any single character
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <strong><code>[</code></strong>chars<strong><code>]</code></strong> Character class: Any character of the class ``chars''
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <strong><code>[^</code></strong>chars<strong><code>]</code></strong> Character class: Not a character of the class ``chars''
06ba4a61654b3763ad65f52283832ebf058fdf1cslive text1<strong><code>|</code></strong>text2 Alternative: text1 or text2
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<strong>Quantifiers:</strong>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <strong><code>?</code></strong> 0 or 1 occurrences of the preceding text
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <strong><code>*</code></strong> 0 or N occurrences of the preceding text (N &gt; 0)
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <strong><code>+</code></strong> 1 or N occurrences of the preceding text (N &gt; 1)
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<strong>Grouping:</strong>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <strong><code>(</code></strong>text<strong><code>)</code></strong> Grouping of text
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem (used either to set the borders of an alternative as above, or
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem to make backreferences, where the <strong>N</strong>th group can
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem be referred to on the RHS of a RewriteRule as <code>$</code><strong>N</strong>)
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<strong>Anchors:</strong>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <strong><code>^</code></strong> Start-of-line anchor
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <strong><code>$</code></strong> End-of-line anchor
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<strong>Escaping:</strong>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <strong><code>\</code></strong>char escape the given char
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem (for instance, to specify the chars "<code>.[]()</code>" <em>etc.</em>)
97a9a944b5887e91042b019776c41d5dd74557aferikabele</pre></div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p>For more information about regular expressions, have a look at the
630c456b6461158be6cc5c5483735e27b13b4ad5nd perl regular expression manpage ("<a href="http://www.perldoc.com/perl5.6.1/pod/perlre.html">perldoc
630c456b6461158be6cc5c5483735e27b13b4ad5nd perlre</a>"). If you are interested in more detailed
06ba4a61654b3763ad65f52283832ebf058fdf1cslive information about regular expressions and their variants
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem (POSIX regex etc.) the following book is dedicated to this topic:</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele <p class="indent">
edc8d9e0cce625a77afd1ff87a8f955694a973e2rbowen <em>Mastering Regular Expressions, 2nd Edition</em><br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele Jeffrey E.F. Friedl<br />
edc8d9e0cce625a77afd1ff87a8f955694a973e2rbowen O'Reilly &amp; Associates, Inc. 2002<br />
edc8d9e0cce625a77afd1ff87a8f955694a973e2rbowen ISBN 0-596-00289-0<br />
97a9a944b5887e91042b019776c41d5dd74557aferikabele </p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p>In mod_rewrite, the NOT character
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem ('<code>!</code>') is also available as a possible pattern
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem prefix. This enables you to negate a pattern; to say, for instance:
06ba4a61654b3763ad65f52283832ebf058fdf1cslive ``<em>if the current URL does <strong>NOT</strong> match this
06ba4a61654b3763ad65f52283832ebf058fdf1cslive pattern</em>''. This can be used for exceptional cases, where
06ba4a61654b3763ad65f52283832ebf058fdf1cslive it is easier to match the negative pattern, or as a last
06ba4a61654b3763ad65f52283832ebf058fdf1cslive default rule.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<div class="note"><h3>Note</h3>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluemWhen using the NOT character to negate a pattern, you cannot include
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluemgrouped wildcard parts in that pattern. This is because, when the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluempattern does NOT match (ie, the negation matches), there are no
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluemcontents for the groups. Thus, if negated patterns are used, you
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluemcannot use <code>$N</code> in the substitution string!
97a9a944b5887e91042b019776c41d5dd74557aferikabele</div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p>The <a id="rhs" name="rhs"><em>substitution</em></a> of a
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem rewrite rule is the string which is substituted for (or
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem replaces) the original URL which <em>Pattern</em>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem matched. In addition to plain text, it can include</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <ol>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>back-references (<code>$N</code>) to the RewriteRule
06ba4a61654b3763ad65f52283832ebf058fdf1cslive pattern</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <li>back-references (<code>%N</code>) to the last matched
06ba4a61654b3763ad65f52283832ebf058fdf1cslive RewriteCond pattern</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>server-variables as in rule condition test-strings
06ba4a61654b3763ad65f52283832ebf058fdf1cslive (<code>%{VARNAME}</code>)</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li><a href="#mapfunc">mapping-function</a> calls
06ba4a61654b3763ad65f52283832ebf058fdf1cslive (<code>${mapname:key|default}</code>)</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </ol>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p>Back-references are identifiers of the form
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>$</code><strong>N</strong>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem (<strong>N</strong>=0..9), which will be replaced
06ba4a61654b3763ad65f52283832ebf058fdf1cslive by the contents of the <strong>N</strong>th group of the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive matched <em>Pattern</em>. The server-variables are the same
06ba4a61654b3763ad65f52283832ebf058fdf1cslive as for the <em>TestString</em> of a <code>RewriteCond</code>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive directive. The mapping-functions come from the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>RewriteMap</code> directive and are explained there.
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem These three types of variables are expanded in the order above.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p>As already mentioned, all rewrite rules are
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem applied to the <em>Substitution</em> (in the order in which
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem they are defined
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem in the config file). The URL is <strong>completely
06ba4a61654b3763ad65f52283832ebf058fdf1cslive replaced</strong> by the <em>Substitution</em> and the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem rewriting process continues until all rules have been applied,
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem or it is explicitly terminated by a
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code><strong>L</strong></code> flag.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>There is a special substitution string named
06ba4a61654b3763ad65f52283832ebf058fdf1cslive '<code>-</code>' which means: <strong>NO
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem substitution</strong>! This is useful in providing
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem rewriting rules which <strong>only</strong> match
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem URLs but do not substitute anything for them. It is commonly used
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem in conjunction with the <strong>C</strong> (chain) flag, in order
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem to apply more than one pattern before substitution occurs.</p>
70373b9ee042e7b3be82eee14b17f510fffdacc9slive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
21f4ac5ab80abe4cbe90ae0f340c29053556c52drbowen <p>Additionally you can set special <a name="rewriteflags" id="rewriteflags">flags</a> for <em>Substitution</em> by
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem appending <strong><code>[</code><em>flags</em><code>]</code></strong>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive as the third argument to the <code>RewriteRule</code>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem directive. <em>Flags</em> is a comma-separated list of any of the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive following flags: </p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <ul>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen <li>'<strong><code>chain|C</code></strong>'
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen (<strong>c</strong>hained with next rule)<br />
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen This flag chains the current rule with the next rule
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen (which itself can be chained with the following rule,
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem and so on). This has the following effect: if a rule
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem matches, then processing continues as usual -
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen the flag has no effect. If the rule does
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen <strong>not</strong> match, then all following chained
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem rules are skipped. For instance, it can be used to remove the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem ``<code>.www</code>'' part, inside a per-directory rule set,
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen when you let an external redirect happen (where the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem ``<code>.www</code>'' part should not occur!).</li>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen '<strong><code>cookie|CO=</code></strong><em>NAME</em>:<em>VAL</em>:<em>domain</em>[:<em>lifetime</em>[:<em>path</em>]]'
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen (set <strong>co</strong>okie)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem This sets a cookie in the client's browser. The cookie's name
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen is specified by <em>NAME</em> and the value is
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen <em>VAL</em>. The <em>domain</em> field is the domain of the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem cookie, such as '.apache.org', the optional <em>lifetime</em>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen is the lifetime of the cookie in minutes, and the optional
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen <em>path</em> is the path of the cookie</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen <li>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen '<strong><code>env|E=</code></strong><em>VAR</em>:<em>VAL</em>'
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen (set <strong>e</strong>nvironment variable)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem This forces an environment variable named <em>VAR</em> to
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen be set to the value <em>VAL</em>, where <em>VAL</em> can
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem contain regexp backreferences (<code>$N</code> and
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>%N</code>) which will be expanded. You can use this
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem flag more than once, to set more than one variable. The
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem variables can later be dereferenced in many situations, most commonly
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem from within XSSI (via <code>&lt;!--#echo
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem var="VAR"--&gt;</code>) or CGI (<code>$ENV{'VAR'}</code>).
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem You can also dereference the variable in a later RewriteCond pattern, using
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>%{ENV:VAR}</code>. Use this to strip
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem information from URLs, while maintaining a record of that information.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>'<strong><code>forbidden|F</code></strong>' (force URL
97a9a944b5887e91042b019776c41d5dd74557aferikabele to be <strong>f</strong>orbidden)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem This forces the current URL to be forbidden - it immediately
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem sends back a HTTP response of 403 (FORBIDDEN).
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Use this flag in conjunction with
06ba4a61654b3763ad65f52283832ebf058fdf1cslive appropriate RewriteConds to conditionally block some
06ba4a61654b3763ad65f52283832ebf058fdf1cslive URLs.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>'<strong><code>gone|G</code></strong>' (force URL to be
97a9a944b5887e91042b019776c41d5dd74557aferikabele <strong>g</strong>one)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem This forces the current URL to be gone - it
06ba4a61654b3763ad65f52283832ebf058fdf1cslive immediately sends back a HTTP response of 410 (GONE). Use
06ba4a61654b3763ad65f52283832ebf058fdf1cslive this flag to mark pages which no longer exist as gone.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen '<strong><code>handler|H</code></strong>=<em>Content-handler</em>'
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen (force Content <strong>h</strong>andler)<br />
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen Force the Content-handler of the target file to be
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen <em>Content-handler</em>. For instance, this can be used to
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem simulate the <code class="module"><a href="/mod/mod_alias.html">mod_alias</a></code> directive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code class="directive"><a href="/mod/mod_alias.html#scriptalias">ScriptAlias</a></code>,
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem which internally forces all files
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen inside the mapped directory to have a handler of
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen ``<code>cgi-script</code>''.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>'<strong><code>last|L</code></strong>'
97a9a944b5887e91042b019776c41d5dd74557aferikabele (<strong>l</strong>ast rule)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Stop the rewriting process here and don't apply any more
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem rewrite rules. This corresponds to the Perl
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>last</code> command or the <code>break</code> command
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem in C. Use this flag to prevent the currently
06ba4a61654b3763ad65f52283832ebf058fdf1cslive rewritten URL from being rewritten further by following
06ba4a61654b3763ad65f52283832ebf058fdf1cslive rules. For example, use it to rewrite the root-path URL
06ba4a61654b3763ad65f52283832ebf058fdf1cslive ('<code>/</code>') to a real one, <em>e.g.</em>,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive '<code>/e/www/</code>'.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>'<strong><code>next|N</code></strong>'
97a9a944b5887e91042b019776c41d5dd74557aferikabele (<strong>n</strong>ext round)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Re-run the rewriting process (starting again with the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem first rewriting rule). This time, the URL to match is no longer
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem the original URL, but rather the URL returned by the last rewriting rule.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive This corresponds to the Perl <code>next</code> command or
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem the <code>continue</code> command in C. Use
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem this flag to restart the rewriting process -
97a9a944b5887e91042b019776c41d5dd74557aferikabele to immediately go to the top of the loop.<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <strong>Be careful not to create an infinite
06ba4a61654b3763ad65f52283832ebf058fdf1cslive loop!</strong></li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen <li>'<strong><code>nocase|NC</code></strong>'
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen (<strong>n</strong>o <strong>c</strong>ase)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem This makes the <em>Pattern</em> case-insensitive,
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem ignoring difference between 'A-Z' and
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen 'a-z' when <em>Pattern</em> is matched against the current
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen URL.</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen '<strong><code>noescape|NE</code></strong>'
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen (<strong>n</strong>o URI <strong>e</strong>scaping of
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen output)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem This flag prevents mod_rewrite from applying the usual URI
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen escaping rules to the result of a rewrite. Ordinarily,
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen special characters (such as '%', '$', ';', and so on)
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen will be escaped into their hexcode equivalents ('%25',
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen '%24', and '%3B', respectively); this flag prevents this
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem from happening. This allows percent symbols to appear in
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen the output, as in
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen<div class="example"><p><code>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen RewriteRule /foo/(.*) /bar?arg=P1\%3d$1 [R,NE]
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen</code></p></div>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen which would turn '<code>/foo/zed</code>' into a safe
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen request for '<code>/bar?arg=P1=zed</code>'.
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen </li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem '<strong><code>nosubreq|NS</code></strong>'
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem (<strong>n</strong>ot for internal
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <strong>s</strong>ub-requests)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem This flag forces the rewriting engine to skip a
06ba4a61654b3763ad65f52283832ebf058fdf1cslive rewriting rule if the current request is an internal
06ba4a61654b3763ad65f52283832ebf058fdf1cslive sub-request. For instance, sub-requests occur internally
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem in Apache when <code class="module"><a href="/mod/mod_include.html">mod_include</a></code> tries to find out
06ba4a61654b3763ad65f52283832ebf058fdf1cslive information about possible directory default files
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem (<code>index.xxx</code> files). On sub-requests it is not
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem always useful, and can even cause errors, if
06ba4a61654b3763ad65f52283832ebf058fdf1cslive the complete set of rules are applied. Use this flag to
97a9a944b5887e91042b019776c41d5dd74557aferikabele exclude some rules.<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem To decide whether or not to use this rule: if you
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem prefix URLs with CGI-scripts, to force them to be
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem processed by the CGI-script, it's likely that you
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem will run into problems (or significant overhead) on
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem sub-requests. In these cases, use this flag.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen '<strong><code>proxy|P</code></strong>' (force
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen <strong>p</strong>roxy)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem This flag forces the substitution part to be internally
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem sent as a proxy request and immediately (rewrite
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem processing stops here) put through the <a href="mod_proxy.html">proxy module</a>. You must make
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen sure that the substitution string is a valid URI
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem (typically starting with
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen <code>http://</code><em>hostname</em>) which can be
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem handled by the Apache proxy module. If not, you will get an
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen error from the proxy module. Use this flag to achieve a
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen more powerful implementation of the <a href="mod_proxy.html#proxypass">ProxyPass</a> directive,
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem to map remote content into the namespace of the local
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen server.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p>Note: <code class="module"><a href="/mod/mod_proxy.html">mod_proxy</a></code> must be enabled in order
9b82bd7c7f2083318e7856831dede324534308bcrbowen to use this flag.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive '<strong><code>passthrough|PT</code></strong>'
06ba4a61654b3763ad65f52283832ebf058fdf1cslive (<strong>p</strong>ass <strong>t</strong>hrough to next
97a9a944b5887e91042b019776c41d5dd74557aferikabele handler)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem This flag forces the rewrite engine to set the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>uri</code> field of the internal
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>request_rec</code> structure to the value of the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>filename</code> field. This flag is just a hack to
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem enable post-processing of the output of
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>RewriteRule</code> directives, using
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>Alias</code>, <code>ScriptAlias</code>,
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>Redirect</code>, and other directives from
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem various URI-to-filename translators. For example, to rewrite
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>/abc</code> to <code>/def</code> using
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code>, and then
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>/def</code> to <code>/ghi</code> using
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code class="module"><a href="/mod/mod_alias.html">mod_alias</a></code>:
97a9a944b5887e91042b019776c41d5dd74557aferikabele<div class="example"><p><code>
97a9a944b5887e91042b019776c41d5dd74557aferikabele RewriteRule ^/abc(.*) /def$1 [PT]<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive Alias /def /ghi
97a9a944b5887e91042b019776c41d5dd74557aferikabele</code></p></div>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem If you omit the <code>PT</code> flag,
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>mod_rewrite</code> will rewrite
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>uri=/abc/...</code> to
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <code>filename=/def/...</code> as a full API-compliant
06ba4a61654b3763ad65f52283832ebf058fdf1cslive URI-to-filename translator should do. Then
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>mod_alias</code> will try to do a
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem URI-to-filename transition, which will fail.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p>Note: <strong>You must use this flag if you want to
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem mix directives from different modules which allow
06ba4a61654b3763ad65f52283832ebf058fdf1cslive URL-to-filename translators</strong>. The typical example
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem is the use of <code class="module"><a href="/mod/mod_alias.html">mod_alias</a></code> and
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code>.</p>
b5407b0669a6a7175c84859e727d133399e4fa51slive
b5407b0669a6a7175c84859e727d133399e4fa51slive <p>The <code>PT</code> flag implies the <code>L</code> flag:
b5407b0669a6a7175c84859e727d133399e4fa51slive rewriting will be stopped in order to pass the request to
b5407b0669a6a7175c84859e727d133399e4fa51slive the next phase of processing.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen <li>'<strong><code>qsappend|QSA</code></strong>'
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen (<strong>q</strong>uery <strong>s</strong>tring
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen <strong>a</strong>ppend)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem This flag forces the rewrite engine to append a query
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem string part of the substitution string to the existing string,
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen instead of replacing it. Use this when you want to add more
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen data to the query string via a rewrite rule.</li>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen <li>'<strong><code>redirect|R</code>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen [=<em>code</em>]</strong>' (force <a id="redirect" name="redirect"><strong>r</strong>edirect</a>)<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem Prefix <em>Substitution</em> with
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen <code>http://thishost[:thisport]/</code> (which makes the
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen new URL a URI) to force a external redirection. If no
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <em>code</em> is given, a HTTP response of 302 (MOVED
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem TEMPORARILY) will be returned. If you want to use other response
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem codes in the range 300-400, simply specify the appropriate number
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen or use one of the following symbolic names:
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen <code>temp</code> (default), <code>permanent</code>,
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>seeother</code>. Use this for rules to
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem canonicalize the URL and return it to the client - to
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem translate ``<code>/~</code>'' into
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem ``<code>/u/</code>'', or to always append a slash to
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen <code>/u/</code><em>user</em>, etc.<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <strong>Note:</strong> When you use this flag, make
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem sure that the substitution field is a valid URL! Otherwise,
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem you will be redirecting to an invalid location. Remember
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem that this flag on its own will only prepend
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>http://thishost[:thisport]/</code> to the URL, and rewriting
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem will continue. Usually, you will want to stop rewriting at this point,
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem and redirect immediately. To stop rewriting, you should add
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem the 'L' flag.
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen </li>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>'<strong><code>skip|S</code></strong>=<em>num</em>'
97a9a944b5887e91042b019776c41d5dd74557aferikabele (<strong>s</strong>kip next rule(s))<br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem This flag forces the rewriting engine to skip the next
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <em>num</em> rules in sequence, if the current rule
06ba4a61654b3763ad65f52283832ebf058fdf1cslive matches. Use this to make pseudo if-then-else constructs:
06ba4a61654b3763ad65f52283832ebf058fdf1cslive The last rule of the then-clause becomes
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>skip=N</code>, where N is the number of rules in the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive else-clause. (This is <strong>not</strong> the same as the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive 'chain|C' flag!)</li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <li>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen '<strong><code>type|T</code></strong>=<em>MIME-type</em>'
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen (force MIME <strong>t</strong>ype)<br />
20189240503ef2c8f5dc6e2248b57faab4b23b5and Force the <a class="glossarylink" href="/glossary.html#mime-type" title="see glossary">MIME-type</a> of the target file to be
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <em>MIME-type</em>. This can be used to
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem set up the content-type based on some conditions.
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen For example, the following snippet allows <code>.php</code> files to
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen be <em>displayed</em> by <code>mod_php</code> if they are called with
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen the <code>.phps</code> extension:
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen <div class="example"><p><code>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen RewriteRule ^(.+\.php)s$ $1 [T=application/x-httpd-php-source]
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen </code></p></div>
173a6aaf8f8d2c818ab71d3781400e521051a565rbowen </li>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </ul>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
beae3b927f4a40ba2f0b84d90cacfa1f0d528babwrowe<div class="note"><h3>Per-directory Rewrites</h3>
beae3b927f4a40ba2f0b84d90cacfa1f0d528babwrowe
beae3b927f4a40ba2f0b84d90cacfa1f0d528babwrowe<p>The rewrite engine may be used in <a href="/howto/htaccess.html">.htaccess</a> files. To enable the
beae3b927f4a40ba2f0b84d90cacfa1f0d528babwrowerewrite engine for these files you need to set
beae3b927f4a40ba2f0b84d90cacfa1f0d528babwrowe"<code>RewriteEngine On</code>" <strong>and</strong>
beae3b927f4a40ba2f0b84d90cacfa1f0d528babwrowe"<code>Options FollowSymLinks</code>" must be enabled. If your
beae3b927f4a40ba2f0b84d90cacfa1f0d528babwroweadministrator has disabled override of <code>FollowSymLinks</code> for
beae3b927f4a40ba2f0b84d90cacfa1f0d528babwrowea user's directory, then you cannot use the rewrite engine. This
beae3b927f4a40ba2f0b84d90cacfa1f0d528babwrowerestriction is required for security reasons.</p>
beae3b927f4a40ba2f0b84d90cacfa1f0d528babwrowe
beae3b927f4a40ba2f0b84d90cacfa1f0d528babwrowe<p>When using the rewrite engine in <code>.htaccess</code> files the
06ba4a61654b3763ad65f52283832ebf058fdf1csliveper-directory prefix (which always is the same for a specific
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluemdirectory) is automatically <em>removed</em> for the pattern matching
06ba4a61654b3763ad65f52283832ebf058fdf1csliveand automatically <em>added</em> after the substitution has been
beae3b927f4a40ba2f0b84d90cacfa1f0d528babwrowedone. This feature is essential for many sorts of rewriting; without
beae3b927f4a40ba2f0b84d90cacfa1f0d528babwrowethis, you would always have to match the parent directory, which is
beae3b927f4a40ba2f0b84d90cacfa1f0d528babwrowenot always possible. There is one exception: If a substitution string
beae3b927f4a40ba2f0b84d90cacfa1f0d528babwrowestarts with <code>http://</code>, then the directory prefix will
beae3b927f4a40ba2f0b84d90cacfa1f0d528babwrowe<strong>not</strong> be added, and an external redirect (or proxy
beae3b927f4a40ba2f0b84d90cacfa1f0d528babwrowethroughput, if using flag <strong>P</strong>) is forced. See the
beae3b927f4a40ba2f0b84d90cacfa1f0d528babwrowe<code class="directive"><a href="#rewritebase">RewriteBase</a></code> directive for
beae3b927f4a40ba2f0b84d90cacfa1f0d528babwrowemore information.</p>
beae3b927f4a40ba2f0b84d90cacfa1f0d528babwrowe
beae3b927f4a40ba2f0b84d90cacfa1f0d528babwrowe<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
beae3b927f4a40ba2f0b84d90cacfa1f0d528babwroweprefix-matching rules as would be applied to <code>.htaccess</code>
beae3b927f4a40ba2f0b84d90cacfa1f0d528babwrowefiles. It is usually simpler, however, to avoid the prefix substitution
beae3b927f4a40ba2f0b84d90cacfa1f0d528babwrowecomplication by putting the rewrite rules in the main server or
beae3b927f4a40ba2f0b84d90cacfa1f0d528babwrowevirtual host context, rather than in a <code class="directive"><a href="/mod/core.html#directory">&lt;Directory&gt;</a></code> section.</p>
beae3b927f4a40ba2f0b84d90cacfa1f0d528babwrowe
beae3b927f4a40ba2f0b84d90cacfa1f0d528babwrowe<p>Although rewrite rules are syntactically permitted in <code class="directive"><a href="/mod/core.html#location">&lt;Location&gt;</a></code> sections, this
beae3b927f4a40ba2f0b84d90cacfa1f0d528babwroweshould never be necessary and is unsupported.</p>
beae3b927f4a40ba2f0b84d90cacfa1f0d528babwrowe
97a9a944b5887e91042b019776c41d5dd74557aferikabele</div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem<div class="note"><h3>Note: Substitution of Absolute URLs</h3>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem When you prefix a substitution field with
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>http://thishost[:thisport]</code>, <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> will automatically strip that
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem out. This auto-reduction on URLs with an implicit
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem external redirect is most useful in
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem combination with a mapping-function which generates the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem hostname part.</p>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p><strong>Remember:</strong> An unconditional external
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem redirect to your own server will not work with the prefix
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>http://thishost</code> because of this feature. To
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem achieve such a self-redirect, you have to use the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <strong>R</strong>-flag.</p>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem</div>
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem
8c8c2e71c84babf0e8c4b35819c7c5b3be014cfenoodl<div class="note"><h3>What is matched?</h3>
8c8c2e71c84babf0e8c4b35819c7c5b3be014cfenoodl <p>The <em>Pattern</em> will initially be matched against the part of the
8c8c2e71c84babf0e8c4b35819c7c5b3be014cfenoodl URL after the hostname and port, and before the query string. If you wish
8c8c2e71c84babf0e8c4b35819c7c5b3be014cfenoodl to match against the hostname, port, or query string, use a
8c8c2e71c84babf0e8c4b35819c7c5b3be014cfenoodl <code class="directive"><a href="#rewritecond">RewriteCond</a></code> with the
8c8c2e71c84babf0e8c4b35819c7c5b3be014cfenoodl <code>%{HTTP_HOST}</code>, <code>%{SERVER_PORT}</code>, or
8c8c2e71c84babf0e8c4b35819c7c5b3be014cfenoodl <code>%{QUERY_STRING}</code> variables respectively.</p>
8c8c2e71c84babf0e8c4b35819c7c5b3be014cfenoodl <p>You can, however, create URLs in the substitution string containing a
8c8c2e71c84babf0e8c4b35819c7c5b3be014cfenoodl query string part. Simply use a question mark inside the substitution
8c8c2e71c84babf0e8c4b35819c7c5b3be014cfenoodl string, to indicate that the following text should be re-injected into the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem query string. When you want to erase an existing query string,
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem end the substitution string with just a question mark. To
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem combine new and old query strings, use the
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <code>[QSA]</code> flag.</p>
97a9a944b5887e91042b019776c41d5dd74557aferikabele</div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem <p>Here are all possible substitution combinations and their
06ba4a61654b3763ad65f52283832ebf058fdf1cslive meanings:</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p><strong>Inside per-server configuration
97a9a944b5887e91042b019776c41d5dd74557aferikabele (<code>httpd.conf</code>)<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive for request ``<code>GET
97a9a944b5887e91042b019776c41d5dd74557aferikabele /somepath/pathinfo</code>'':</strong><br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele<div class="note"><pre>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<strong>Given Rule</strong> <strong>Resulting Substitution</strong>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive---------------------------------------------- ----------------------------------
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem^/somepath(.*) otherpath$1 invalid, not supported
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem^/somepath(.*) otherpath$1 [R] invalid, not supported
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem^/somepath(.*) otherpath$1 [P] invalid, not supported
06ba4a61654b3763ad65f52283832ebf058fdf1cslive---------------------------------------------- ----------------------------------
06ba4a61654b3763ad65f52283832ebf058fdf1cslive^/somepath(.*) /otherpath$1 /otherpath/pathinfo
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive^/somepath(.*) /otherpath$1 [R] http://thishost/otherpath/pathinfo
06ba4a61654b3763ad65f52283832ebf058fdf1cslive via external redirection
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem^/somepath(.*) /otherpath$1 [P] doesn't make sense, not supported
06ba4a61654b3763ad65f52283832ebf058fdf1cslive---------------------------------------------- ----------------------------------
06ba4a61654b3763ad65f52283832ebf058fdf1cslive^/somepath(.*) http://thishost/otherpath$1 /otherpath/pathinfo
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive^/somepath(.*) http://thishost/otherpath$1 [R] http://thishost/otherpath/pathinfo
06ba4a61654b3763ad65f52283832ebf058fdf1cslive via external redirection
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem^/somepath(.*) http://thishost/otherpath$1 [P] doesn't make sense, not supported
06ba4a61654b3763ad65f52283832ebf058fdf1cslive---------------------------------------------- ----------------------------------
06ba4a61654b3763ad65f52283832ebf058fdf1cslive^/somepath(.*) http://otherhost/otherpath$1 http://otherhost/otherpath/pathinfo
06ba4a61654b3763ad65f52283832ebf058fdf1cslive via external redirection
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive^/somepath(.*) http://otherhost/otherpath$1 [R] http://otherhost/otherpath/pathinfo
06ba4a61654b3763ad65f52283832ebf058fdf1cslive via external redirection
06ba4a61654b3763ad65f52283832ebf058fdf1cslive (the [R] flag is redundant)
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive^/somepath(.*) http://otherhost/otherpath$1 [P] http://otherhost/otherpath/pathinfo
06ba4a61654b3763ad65f52283832ebf058fdf1cslive via internal proxy
97a9a944b5887e91042b019776c41d5dd74557aferikabele</pre></div>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p><strong>Inside per-directory configuration for
97a9a944b5887e91042b019776c41d5dd74557aferikabele <code>/somepath</code><br />
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem (<code>/physical/path/to/somepath/.htacccess</code>, with
97a9a944b5887e91042b019776c41d5dd74557aferikabele <code>RewriteBase /somepath</code>)<br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive for request ``<code>GET
97a9a944b5887e91042b019776c41d5dd74557aferikabele /somepath/localpath/pathinfo</code>'':</strong><br />
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
97a9a944b5887e91042b019776c41d5dd74557aferikabele<div class="note"><pre>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive<strong>Given Rule</strong> <strong>Resulting Substitution</strong>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive---------------------------------------------- ----------------------------------
06ba4a61654b3763ad65f52283832ebf058fdf1cslive^localpath(.*) otherpath$1 /somepath/otherpath/pathinfo
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive^localpath(.*) otherpath$1 [R] http://thishost/somepath/otherpath/pathinfo
06ba4a61654b3763ad65f52283832ebf058fdf1cslive via external redirection
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem^localpath(.*) otherpath$1 [P] doesn't make sense, not supported
06ba4a61654b3763ad65f52283832ebf058fdf1cslive---------------------------------------------- ----------------------------------
06ba4a61654b3763ad65f52283832ebf058fdf1cslive^localpath(.*) /otherpath$1 /otherpath/pathinfo
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive^localpath(.*) /otherpath$1 [R] http://thishost/otherpath/pathinfo
06ba4a61654b3763ad65f52283832ebf058fdf1cslive via external redirection
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem^localpath(.*) /otherpath$1 [P] doesn't make sense, not supported
06ba4a61654b3763ad65f52283832ebf058fdf1cslive---------------------------------------------- ----------------------------------
06ba4a61654b3763ad65f52283832ebf058fdf1cslive^localpath(.*) http://thishost/otherpath$1 /otherpath/pathinfo
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive^localpath(.*) http://thishost/otherpath$1 [R] http://thishost/otherpath/pathinfo
06ba4a61654b3763ad65f52283832ebf058fdf1cslive via external redirection
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
bf380c59be3f235bde21f1c00098e09e3cf7e7aerpluem^localpath(.*) http://thishost/otherpath$1 [P] doesn't make sense, not supported
06ba4a61654b3763ad65f52283832ebf058fdf1cslive---------------------------------------------- ----------------------------------
06ba4a61654b3763ad65f52283832ebf058fdf1cslive^localpath(.*) http://otherhost/otherpath$1 http://otherhost/otherpath/pathinfo
06ba4a61654b3763ad65f52283832ebf058fdf1cslive via external redirection
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive^localpath(.*) http://otherhost/otherpath$1 [R] http://otherhost/otherpath/pathinfo
06ba4a61654b3763ad65f52283832ebf058fdf1cslive via external redirection
06ba4a61654b3763ad65f52283832ebf058fdf1cslive (the [R] flag is redundant)
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive^localpath(.*) http://otherhost/otherpath$1 [P] http://otherhost/otherpath/pathinfo
06ba4a61654b3763ad65f52283832ebf058fdf1cslive via internal proxy
97a9a944b5887e91042b019776c41d5dd74557aferikabele</pre></div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</div>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd</div>
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd<div class="bottomlang">
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd<p><span>Available Languages: </span><a href="/en/mod/mod_rewrite.html" title="English">&nbsp;en&nbsp;</a></p>
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd</div><div id="footer">
4b22542f6f38567cae7873b176188a6622f67eb0fielding<p class="apache">Copyright 2006 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>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="/faq/">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p></div>
611049e38bfbaeb173d2d7fab2e44a48753436a1nd</body></html>