-<html><head><META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><!--
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
This file is generated from xml source: DO NOT EDIT
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
- --><title>mod_rewrite - Apache HTTP Server</title><link href="../style/manual.css" type="text/css" rel="stylesheet"></head><body><blockquote><div align="center"><img src="../images/sub.gif" alt="[APACHE DOCUMENTATION]"><h3>Apache HTTP Server Version 2.0</h3></div><h1 align="center">Apache Module mod_rewrite</h1><table cellspacing="1" cellpadding="0" bgcolor="#cccccc"><tr><td><table bgcolor="#ffffff"><tr><td nowrap="nowrap" valign="top"><span class="help">Description:
- </span></td><td>Provides a rule-based rewriting engine to rewrite requested
-URLs on the fly</td></tr><tr><td nowrap="nowrap"><a href="module-dict.html#Status" class="help">Status:
- </a></td><td>Extension</td></tr><tr><td nowrap="nowrap"><a href="module-dict.html#ModuleIdentifier" class="help">Module Identifier:
- </a></td><td>rewrite_module</td></tr><tr><td align="left" valign="top"><a href="module-dict.html#Compatibility" class="help">Compatibility:
- </a></td><td><compatibility>Available in Apache 1.3 and later</compatibility></td></tr></table></td></tr></table><h2>Summary</h2>
+ -->
+<title>mod_rewrite - Apache HTTP Server</title>
+<link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
+<link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
+<link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
+<link href="../images/favicon.ico" rel="shortcut icon" /></head>
+<body>
+<div id="page-header">
+<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>
+<p class="apache">Apache HTTP Server Version 2.1</p>
+<img alt="" src="../images/feather.gif" /></div>
+<div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div>
+<div id="path">
+<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs-project/">Documentation</a> > <a href="../">Version 2.1</a> > <a href="./">Modules</a></div>
+<div id="page-content">
+<div id="preamble"><h1>Apache Module mod_rewrite</h1>
+<div class="toplang">
+<p><span>Available Languages: </span><a href="../en/mod/mod_rewrite.html" title="English"> en </a></p>
+</div>
+<table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Provides a rule-based rewriting engine to rewrite requested
+URLs on the fly</td></tr>
+<tr><th><a href="module-dict.html#Status">Status:</a></th><td>Extension</td></tr>
+<tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>rewrite_module</td></tr>
+<tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>mod_rewrite.c</td></tr>
+<tr><th><a href="module-dict.html#Compatibility">Compatibility:</a></th><td>Available in Apache 1.3 and later</td></tr></table>
+<h3>Summary</h3>
+
<blockquote>
- <em>``The great thing about mod_rewrite is it gives you
+ <p>``The great thing about mod_rewrite is it gives you
all the configurability and flexibility of Sendmail.
The downside to mod_rewrite is that it gives you all
- the configurability and flexibility of Sendmail.''</em><br>
+ the configurability and flexibility of Sendmail.''</p>
- -- Brian Behlendorf<br>
- Apache Group
+ <p class="cite">-- <cite>Brian Behlendorf</cite><br />
+ Apache Group</p>
</blockquote>
<blockquote>
- <em>`` Despite the tons of examples and docs,
+ <p>`` Despite the tons of examples and docs,
mod_rewrite is voodoo. Damned cool voodoo, but still
- voodoo. ''</em> <br>
+ voodoo. ''</p>
- -- Brian Moore<br>
- bem@news.cmc.net
+ <p class="cite">-- <cite>Brian Moore</cite><br />
+ bem@news.cmc.net</p>
- </blockquote>
+ </blockquote>
<p>Welcome to mod_rewrite, the Swiss Army Knife of URL
1996 and gifted exclusively to the The Apache Group in July 1997
by</p>
- <blockquote>
+ <p class="indent">
<a href="http://www.engelschall.com/"><code>Ralf S.
- Engelschall</code></a><br>
- <a href="mailto:rse@engelschall.com"><code>rse@engelschall.com</code></a><br>
+ Engelschall</code></a><br />
+ <a href="mailto:rse@engelschall.com"><code>rse@engelschall.com</code></a><br />
<a href="http://www.engelschall.com/"><code>www.engelschall.com</code></a>
- </blockquote>
-<h2>Directives</h2><ul><li><a href="#rewritebase">RewriteBase</a></li><li><a href="#rewritecond">RewriteCond</a></li><li><a href="#rewriteengine">RewriteEngine</a></li><li><a href="#rewritelock">RewriteLock</a></li><li><a href="#rewritelog">RewriteLog</a></li><li><a href="#rewriteloglevel">RewriteLogLevel</a></li><li><a href="#rewritemap">RewriteMap</a></li><li><a href="#rewriteoptions">RewriteOptions</a></li><li><a href="#rewriterule">RewriteRule</a></li></ul><h2><a name="Internal">Interal Processing</a></h2>
+ </p>
+</div>
+<div id="quickview"><h3 class="directives">Directives</h3>
+<ul id="toc">
+<li><img alt="" src="../images/down.gif" /> <a href="#rewritebase">RewriteBase</a></li>
+<li><img alt="" src="../images/down.gif" /> <a href="#rewritecond">RewriteCond</a></li>
+<li><img alt="" src="../images/down.gif" /> <a href="#rewriteengine">RewriteEngine</a></li>
+<li><img alt="" src="../images/down.gif" /> <a href="#rewritelock">RewriteLock</a></li>
+<li><img alt="" src="../images/down.gif" /> <a href="#rewritelog">RewriteLog</a></li>
+<li><img alt="" src="../images/down.gif" /> <a href="#rewriteloglevel">RewriteLogLevel</a></li>
+<li><img alt="" src="../images/down.gif" /> <a href="#rewritemap">RewriteMap</a></li>
+<li><img alt="" src="../images/down.gif" /> <a href="#rewriteoptions">RewriteOptions</a></li>
+<li><img alt="" src="../images/down.gif" /> <a href="#rewriterule">RewriteRule</a></li>
+</ul>
+<h3>Topics</h3>
+<ul id="topics">
+<li><img alt="" src="../images/down.gif" /> <a href="#Internal">Internal Processing</a></li>
+<li><img alt="" src="../images/down.gif" /> <a href="#EnvVar">Environment Variables</a></li>
+<li><img alt="" src="../images/down.gif" /> <a href="#Solutions">Practical Solutions</a></li>
+</ul></div>
+<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
+<div class="section">
+<h2><a name="Internal" id="Internal">Internal Processing</a></h2>
<p>The internal processing of this module is very complex but
needs to be explained once even to the average user to avoid
common mistakes and to let you exploit its full
functionality.</p>
-<h3><a name="InternalAPI">API Phases</a></h3>
+<h3><a name="InternalAPI" id="InternalAPI">API Phases</a></h3>
<p>First you have to understand that when Apache processes a
HTTP request it does this in phases. A hook for each of these
<p>Don't forget these two points!</p>
-<h3><a name="InternalRuleset">Ruleset Processing</a></h3>
+<h3><a name="InternalRuleset" id="InternalRuleset">Ruleset Processing</a></h3>
<p>Now when mod_rewrite is triggered in these two API phases, it
reads the configured rulesets from its configuration
<p>The order of rules in the ruleset is important because the
rewriting engine processes them in a special (and not very
obvious) order. The rule is this: The rewriting engine loops
- through the ruleset rule by rule (<a href="#rewriterule" class="directive"><code class="directive">RewriteRule</code></a> directives) and
+ through the ruleset rule by rule (<code class="directive"><a href="#rewriterule">RewriteRule</a></code> directives) and
when a particular rule matches it optionally loops through
existing corresponding conditions (<code>RewriteCond</code>
directives). For historical reasons the conditions are given
first, and so the control flow is a little bit long-winded. See
Figure 1 for more details.</p>
-<blockquote>
- <img src="../images/mod_rewrite_fig1.gif" border="1" width="428" height="385" alt="[Needs graphics capability to display]">
- <p><strong>Figure 1:</strong>The control flow through the rewriting ruleset</p>
-</blockquote>
+<p class="figure">
+ <img src="../images/mod_rewrite_fig1.gif" width="428" height="385" alt="[Needs graphics capability to display]" /><br />
+ <dfn>Figure 1:</dfn>The control flow through the rewriting ruleset
+</p>
<p>As you can see, first the URL is matched against the
<em>Pattern</em> of each rule. When it fails mod_rewrite
immediately stops processing this rule and continues with the
-<h3><a name="quoting">Quoting Special Characters</a></h3>
+<h3><a name="quoting" id="quoting">Quoting Special Characters</a></h3>
<p>As of Apache 1.3.20, special characters in
<em>TestString</em> and <em>Substitution</em> strings can be
to treat it as a backreference.</p>
-<h3><a name="InternalBackRefs">Regex Back-Reference Availability</a></h3>
+<h3><a name="InternalBackRefs" id="InternalBackRefs">Regex Back-Reference Availability</a></h3>
<p>One important thing here has to be remembered: Whenever you
use parentheses in <em>Pattern</em> or in one of the
<code>%N</code> (see below). These are available for creating
the strings <em>Substitution</em> and <em>TestString</em>.
Figure 2 shows to which locations the back-references are
- transfered for expansion.</p>
+ transferred for expansion.</p>
-<blockquote>
- <img src="../images/mod_rewrite_fig2.gif" border="1" width="381" height="179" alt="[Needs graphics capability to display]">
- <p><strong>Figure 2:</strong> The back-reference flow through a rule.</p>
-</blockquote>
+<p class="figure">
+ <img src="../images/mod_rewrite_fig2.gif" width="381" height="179" alt="[Needs graphics capability to display]" /><br />
+ <dfn>Figure 2:</dfn> The back-reference flow through a rule.
+</p>
<p>We know this was a crash course on mod_rewrite's internal
processing. But you will benefit from this knowledge when
reading the following documentation of the available
directives.</p>
-<h2><a name="EnvVar">Environment Variables</a></h2>
+</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
+<div class="section">
+<h2><a name="EnvVar" id="EnvVar">Environment Variables</a></h2>
<p>This module keeps track of two additional (non-standard)
CGI/SSI environment variables named <code>SCRIPT_URL</code>
primarily used to rewrite logical URLs to physical
pathnames.</p>
- <p><strong>Example:</strong></p>
-
-<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
-<pre>
+<div class="example"><h3>Example</h3><pre>
SCRIPT_NAME=/sw/lib/w3s/tree/global/u/rse/.www/index.html
SCRIPT_FILENAME=/u/rse/.www/index.html
SCRIPT_URL=/u/rse/
SCRIPT_URI=http://en1.engelschall.com/u/rse/
-</pre>
-</code></td></tr></table></blockquote>
+</pre></div>
-<h2><a name="Solutions">Practical Solutions</a></h2>
+</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
+<div class="section">
+<h2><a name="Solutions" id="Solutions">Practical Solutions</a></h2>
<p>We also have an <a href="../misc/rewriteguide.html">URL
Rewriting Guide</a> available, which provides a collection of
practical solutions for URL-based problems. There you can
find real-life rulesets and additional information about
mod_rewrite.</p>
-<hr><h2><a name="RewriteBase">RewriteBase</a> <a name="rewritebase">Directive</a></h2><table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc"><tr><td><table bgcolor="#ffffff"><tr><td nowrap="nowrap"><strong>Description:
- </strong></td><td>Sets the base URL for per-directory rewrites</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Syntax" class="help">Syntax:
- </a></td><td>RewriteBase <em>URL-path</em></td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Default" class="help">Default:
- </a></td><td><code>See usage for information.</code></td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Context" class="help">Context:
- </a></td><td>directory, .htaccess</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Override" class="help">Override:
- </a></td><td>FileInfo</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Status" class="help">Status:
- </a></td><td>Extension</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Module" class="help">Module:
- </a></td><td>mod_rewrite</td></tr></table></td></tr></table>
+</div>
+<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
+<div class="directive-section"><h2><a name="RewriteBase" id="RewriteBase">RewriteBase</a> <a name="rewritebase" id="rewritebase">Directive</a></h2>
+<table class="directive">
+<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets the base URL for per-directory rewrites</td></tr>
+<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteBase <em>URL-path</em></code></td></tr>
+<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>See usage for information.</code></td></tr>
+<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>directory, .htaccess</td></tr>
+<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
+<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
+<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
+</table>
<p>The <code class="directive">RewriteBase</code> directive explicitly
sets the base URL for per-directory rewrites. As you will see
- below, <a href="#rewriterule" class="directive"><code class="directive">RewriteRule</code></a>
+ below, <code class="directive"><a href="#rewriterule">RewriteRule</a></code>
can be used in per-directory config files
(<code>.htaccess</code>). There it will act locally,
<em>i.e.</em>, the local directory prefix is stripped at this
use the <code>RewriteBase</code> directive to specify the
correct URL-prefix.</p>
-<blockquote><table><tr><td bgcolor="#e0e5f5"> If your webserver's URLs are <strong>not</strong> directly
+<div class="note"> If your webserver's URLs are <strong>not</strong> directly
related to physical file paths, you have to use
<code class="directive">RewriteBase</code> in every <code>.htaccess</code>
-files where you want to use <a href="#rewriterule" class="directive"><code class="directive">RewriteRule</code></a> directives.
-</td></tr></table></blockquote>
+files where you want to use <code class="directive"><a href="#rewriterule">RewriteRule</a></code> directives.
+</div>
<p> For example, assume the following per-directory config file:</p>
-<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
-<pre>
+<div class="example"><pre>
#
# /abc/def/.htaccess -- per-dir config file for directory /abc/def
# Remember: /abc/def is the physical path of /xyz, <em>i.e.</em>, the server
# now the rewriting rules
RewriteRule ^oldstuff\.html$ newstuff.html
-</pre>
-</code></td></tr></table></blockquote>
+</pre></div>
<p>In the above example, a request to
<code>/xyz/oldstuff.html</code> gets correctly rewritten to
the physical file <code>/abc/def/newstuff.html</code>.</p>
-<blockquote><table><tr><td bgcolor="#e0e5f5"><p align="center"><strong>For Apache Hackers</strong></p>
+<div class="note"><h3>For Apache Hackers</h3>
<p>The following list gives detailed information about
the internal processing steps:</p>
<pre>
procedure is used by many other operations inside
Apache. So, you can be sure the design and
implementation is correct.</p>
-</td></tr></table></blockquote>
-
-<hr><h2><a name="RewriteCond">RewriteCond</a> <a name="rewritecond">Directive</a></h2><table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc"><tr><td><table bgcolor="#ffffff"><tr><td nowrap="nowrap"><strong>Description:
- </strong></td><td>Defines a condition under which rewriting will take place
-</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Syntax" class="help">Syntax:
- </a></td><td> RewriteCond
- <em>TestString</em> <em>CondPattern</em></td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Default" class="help">Default:
- </a></td><td><code>None</code></td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Context" class="help">Context:
- </a></td><td>server config, virtual host, directory, .htaccess</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Override" class="help">Override:
- </a></td><td>FileInfo</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Status" class="help">Status:
- </a></td><td>Extension</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Module" class="help">Module:
- </a></td><td>mod_rewrite</td></tr></table></td></tr></table>
+</div>
+
+
+</div>
+<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
+<div class="directive-section"><h2><a name="RewriteCond" id="RewriteCond">RewriteCond</a> <a name="rewritecond" id="rewritecond">Directive</a></h2>
+<table class="directive">
+<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Defines a condition under which rewriting will take place
+</td></tr>
+<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code> RewriteCond
+ <em>TestString</em> <em>CondPattern</em></code></td></tr>
+<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
+<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
+<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
+<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
+</table>
<p>The <code class="directive">RewriteCond</code> directive defines a
- rule condition. Precede a <a href="#rewriterule" class="directive"><code class="directive">RewriteRule</code></a> directive with one
+ rule condition. Precede a <code class="directive"><a href="#rewriterule">RewriteRule</a></code> directive with one
or more <code class="directive">RewriteCond</code> directives. The following
rewriting rule is only used if its pattern matches the current
state of the URI <strong>and</strong> if these additional
<strong>RewriteRule backreferences</strong>: These are
backreferences of the form
- <blockquote>
+ <p class="indent">
<strong><code>$N</code></strong>
- </blockquote>
+ </p>
(0 <= N <= 9) which provide access to the grouped
parts (parenthesis!) of the pattern from the
corresponding <code>RewriteRule</code> directive (the one
<strong>RewriteCond backreferences</strong>: These are
backreferences of the form
- <blockquote>
+ <p class="indent">
<strong><code>%N</code></strong>
- </blockquote>
+ </p>
(1 <= N <= 9) which provide access to the grouped
parts (parentheses!) of the pattern from the last matched
<code>RewriteCond</code> directive in the current bunch
<strong>RewriteMap expansions</strong>: These are
expansions of the form
- <blockquote>
+ <p class="indent">
<strong><code>${mapname:key|default}</code></strong>
- </blockquote>
+ </p>
See <a href="#mapfunc">the documentation for
RewriteMap</a> for more details.
</li>
<strong>Server-Variables</strong>: These are variables of
the form
- <blockquote>
+ <p class="indent">
<strong><code>%{</code> <em>NAME_OF_VARIABLE</em>
<code>}</code></strong>
- </blockquote>
+ </p>
where <em>NAME_OF_VARIABLE</em> can be a string taken
from the following list:
- <table bgcolor="#F0F0F0" cellspacing="0" cellpadding="5">
+ <table>
+
<tr>
- <td>
- <strong>HTTP headers:</strong>
-
- <p>HTTP_USER_AGENT<br>
- HTTP_REFERER<br>
- HTTP_COOKIE<br>
- HTTP_FORWARDED<br>
- HTTP_HOST<br>
- HTTP_PROXY_CONNECTION<br>
- HTTP_ACCEPT<br>
- </p>
+ <th>HTTP headers:</th> <th>connection & request:</th> <th />
+ </tr>
+
+ <tr>
+ <td>
+ HTTP_USER_AGENT<br />
+ HTTP_REFERER<br />
+ HTTP_COOKIE<br />
+ HTTP_FORWARDED<br />
+ HTTP_HOST<br />
+ HTTP_PROXY_CONNECTION<br />
+ HTTP_ACCEPT<br />
</td>
<td>
- <strong>connection & request:</strong>
-
- <p>REMOTE_ADDR<br>
- REMOTE_HOST<br>
- REMOTE_USER<br>
- REMOTE_IDENT<br>
- REQUEST_METHOD<br>
- SCRIPT_FILENAME<br>
- PATH_INFO<br>
- QUERY_STRING<br>
- AUTH_TYPE<br>
- </p>
+ REMOTE_ADDR<br />
+ REMOTE_HOST<br />
+ REMOTE_PORT<br />
+ REMOTE_USER<br />
+ REMOTE_IDENT<br />
+ REQUEST_METHOD<br />
+ SCRIPT_FILENAME<br />
+ PATH_INFO<br />
+ QUERY_STRING<br />
+ AUTH_TYPE<br />
</td>
+
+ <td />
</tr>
<tr>
- <td>
- <strong>server internals:</strong>
-
- <p>DOCUMENT_ROOT<br>
- SERVER_ADMIN<br>
- SERVER_NAME<br>
- SERVER_ADDR<br>
- SERVER_PORT<br>
- SERVER_PROTOCOL<br>
- SERVER_SOFTWARE<br>
- </p>
+ <th>server internals:</th> <th>system stuff:</th> <th>specials:</th>
+ </tr>
+
+ <tr>
+ <td>
+ DOCUMENT_ROOT<br />
+ SERVER_ADMIN<br />
+ SERVER_NAME<br />
+ SERVER_ADDR<br />
+ SERVER_PORT<br />
+ SERVER_PROTOCOL<br />
+ SERVER_SOFTWARE<br />
</td>
<td>
- <strong>system stuff:</strong>
-
- <p>TIME_YEAR<br>
- TIME_MON<br>
- TIME_DAY<br>
- TIME_HOUR<br>
- TIME_MIN<br>
- TIME_SEC<br>
- TIME_WDAY<br>
- TIME<br>
- </p>
+ TIME_YEAR<br />
+ TIME_MON<br />
+ TIME_DAY<br />
+ TIME_HOUR<br />
+ TIME_MIN<br />
+ TIME_SEC<br />
+ TIME_WDAY<br />
+ TIME<br />
</td>
<td>
- <strong>specials:</strong>
-
- <p>API_VERSION<br>
- THE_REQUEST<br>
- REQUEST_URI<br>
- REQUEST_FILENAME<br>
- IS_SUBREQ<br>
- </p>
+ API_VERSION<br />
+ THE_REQUEST<br />
+ REQUEST_URI<br />
+ REQUEST_FILENAME<br />
+ IS_SUBREQ<br />
+ HTTPS<br />
</td>
</tr>
</table>
-<blockquote><table><tr><td bgcolor="#e0e5f5">
+<div class="note">
<p>These variables all
correspond to the similarly named HTTP
MIME-headers, C variables of the Apache server or
<dd>The full local filesystem path to the file or
script matching the request.</dd>
+
+ <dt><code>HTTPS</code></dt>
+
+ <dd>Will contain the text "on" if the connection is
+ using SSL/TLS, or "off" otherwise. (This variable
+ can be safely used regardless of whether
+ <code class="module"><a href="../mod/mod_ssl.html">mod_ssl</a></code> is loaded).</dd>
+
</dl>
-</td></tr></table></blockquote>
+</div>
</li>
</ul>
Apache structures and (if not found there) via
<code>getenv()</code> from the Apache server process.</li>
+ <li>There is the special format:
+ <code>%{SSL:variable}</code> where <em>variable</em> is the
+ name of an <a href="mod_ssl.html#envvars">SSL environment
+ variable</a>; this can be used whether or not
+ <code class="module"><a href="../mod/mod_ssl.html">mod_ssl</a></code> is loaded, but will always expand to
+ the empty string if it is not. Example:
+ <code>%{SSL:SSL_CIPHER_USEKEYSIZE}</code> may expand to
+ <code>128</code>.</li>
+
<li>There is the special format:
<code>%{HTTP:header}</code> where <em>header</em> can be
any HTTP MIME-header name. This is looked-up from the HTTP
<em>CondPattern</em>.</p>
<p><strong>Remember:</strong> <em>CondPattern</em> is a
- standard <em>Extended Regular Expression</em> with some
+ <em>perl compatible regular expression</em> with some
additions:</p>
<ol>
<ul>
<li>'<strong><CondPattern</strong>' (is lexically
- lower)<br>
+ lower)<br />
Treats the <em>CondPattern</em> as a plain string and
compares it lexically to <em>TestString</em>. True if
<em>TestString</em> is lexically lower than
<em>CondPattern</em>.</li>
<li>'<strong>>CondPattern</strong>' (is lexically
- greater)<br>
+ greater)<br />
Treats the <em>CondPattern</em> as a plain string and
compares it lexically to <em>TestString</em>. True if
<em>TestString</em> is lexically greater than
<em>CondPattern</em>.</li>
<li>'<strong>=CondPattern</strong>' (is lexically
- equal)<br>
+ equal)<br />
Treats the <em>CondPattern</em> as a plain string and
compares it lexically to <em>TestString</em>. True if
<em>TestString</em> is lexically equal to
compares <em>TestString</em> to the empty string.</li>
<li>'<strong>-d</strong>' (is
- <strong>d</strong>irectory)<br>
+ <strong>d</strong>irectory)<br />
Treats the <em>TestString</em> as a pathname and tests
if it exists and is a directory.</li>
<li>'<strong>-f</strong>' (is regular
- <strong>f</strong>ile)<br>
+ <strong>f</strong>ile)<br />
Treats the <em>TestString</em> as a pathname and tests
if it exists and is a regular file.</li>
<li>'<strong>-s</strong>' (is regular file with
- <strong>s</strong>ize)<br>
+ <strong>s</strong>ize)<br />
Treats the <em>TestString</em> as a pathname and tests
if it exists and is a regular file with size greater
than zero.</li>
<li>'<strong>-l</strong>' (is symbolic
- <strong>l</strong>ink)<br>
+ <strong>l</strong>ink)<br />
Treats the <em>TestString</em> as a pathname and tests
if it exists and is a symbolic link.</li>
+ <li>'<strong>-x</strong>' (has e<strong>x</strong>ecutable
+ permissions)<br />
+ Treats the <em>TestString</em> as a pathname and tests
+ if it exists and has execution permissions. These permissions
+ are determined depending on the underlying OS.</li>
+
<li>'<strong>-F</strong>' (is existing file via
- subrequest)<br>
+ subrequest)<br />
Checks if <em>TestString</em> is a valid file and
accessible via all the server's currently-configured
access controls for that path. This uses an internal
because it decreases your servers performance!</li>
<li>'<strong>-U</strong>' (is existing URL via
- subrequest)<br>
+ subrequest)<br />
Checks if <em>TestString</em> is a valid URL and
accessible via all the server's currently-configured
access controls for that path. This uses an internal
because it decreases your server's performance!</li>
</ul>
-<blockquote><table><tr><td bgcolor="#e0e5f5"><p align="center"><strong>Notice</strong></p>
+<div class="note"><h3>Notice</h3>
All of these tests can
also be prefixed by an exclamation mark ('!') to
negate their meaning.
-</td></tr></table></blockquote>
+</div>
</li>
</ol>
<p>Additionally you can set special flags for
<em>CondPattern</em> by appending</p>
- <blockquote>
+ <p class="indent">
<strong><code>[</code><em>flags</em><code>]</code></strong>
- </blockquote>
+ </p>
<p>as the third argument to the <code>RewriteCond</code>
directive. <em>Flags</em> is a comma-separated list of the
<ul>
<li>'<strong><code>nocase|NC</code></strong>'
- (<strong>n</strong>o <strong>c</strong>ase)<br>
+ (<strong>n</strong>o <strong>c</strong>ase)<br />
This makes the test case-insensitive, <em>i.e.</em>, there
is no difference between 'A-Z' and 'a-z' both in the
expanded <em>TestString</em> and the <em>CondPattern</em>.
<li>
'<strong><code>ornext|OR</code></strong>'
- (<strong>or</strong> next condition)<br>
+ (<strong>or</strong> next condition)<br />
Use this to combine rule conditions with a local OR
instead of the implicit AND. Typical example:
-<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
-<pre>
+<div class="example"><pre>
RewriteCond %{REMOTE_HOST} ^host1.* [OR]
RewriteCond %{REMOTE_HOST} ^host2.* [OR]
RewriteCond %{REMOTE_HOST} ^host3.*
RewriteRule ...some special stuff for any of these hosts...
-</pre>
-</code></td></tr></table></blockquote>
+</pre></div>
Without this flag you would have to write the cond/rule
three times.
``<code>User-Agent:</code>'' header of the request, you can
use the following: </p>
-<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
-<pre>
+<div class="example"><pre>
RewriteCond %{HTTP_USER_AGENT} ^Mozilla.*
RewriteRule ^/$ /homepage.max.html [L]
RewriteRule ^/$ /homepage.min.html [L]
RewriteRule ^/$ /homepage.std.html [L]
-</pre>
-</code></td></tr></table></blockquote>
+</pre></div>
<p>Interpretation: If you use Netscape Navigator as your
browser (which identifies itself as 'Mozilla'), then you
tables, <em>etc.</em> If you use any other browser you get
the standard homepage.</p>
-<hr><h2><a name="RewriteEngine">RewriteEngine</a> <a name="rewriteengine">Directive</a></h2><table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc"><tr><td><table bgcolor="#ffffff"><tr><td nowrap="nowrap"><strong>Description:
- </strong></td><td>Enables or disables runtime rewriting engine</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Syntax" class="help">Syntax:
- </a></td><td>RewriteEngine on|off</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Default" class="help">Default:
- </a></td><td><code>RewriteEngine off</code></td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Context" class="help">Context:
- </a></td><td>server config, virtual host, directory, .htaccess</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Override" class="help">Override:
- </a></td><td>FileInfo</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Status" class="help">Status:
- </a></td><td>Extension</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Module" class="help">Module:
- </a></td><td>mod_rewrite</td></tr></table></td></tr></table>
+
+</div>
+<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
+<div class="directive-section"><h2><a name="RewriteEngine" id="RewriteEngine">RewriteEngine</a> <a name="rewriteengine" id="rewriteengine">Directive</a></h2>
+<table class="directive">
+<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Enables or disables runtime rewriting engine</td></tr>
+<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteEngine on|off</code></td></tr>
+<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>RewriteEngine off</code></td></tr>
+<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
+<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
+<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
+<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
+</table>
<p>The <code class="directive">RewriteEngine</code> directive enables or
disables the runtime rewriting engine. If it is set to
environment variables.</p>
<p>Use this directive to disable the module instead of
- commenting out all the <a href="#rewriterule" class="directive"><code class="directive">RewriteRule</code></a> directives!</p>
+ commenting out all the <code class="directive"><a href="#rewriterule">RewriteRule</a></code> directives!</p>
<p>Note that, by default, rewrite configurations are not
inherited. This means that you need to have a
<code>RewriteEngine on</code> directive for each virtual host
in which you wish to use it.</p>
-<hr><h2><a name="RewriteLock">RewriteLock</a> <a name="rewritelock">Directive</a></h2><table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc"><tr><td><table bgcolor="#ffffff"><tr><td nowrap="nowrap"><strong>Description:
- </strong></td><td>Sets the name of the lock file used for RewriteMap
-synchronization</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Syntax" class="help">Syntax:
- </a></td><td>RewriteLock <em>file-path</em></td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Default" class="help">Default:
- </a></td><td><code>None</code></td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Context" class="help">Context:
- </a></td><td>server config</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Status" class="help">Status:
- </a></td><td>Extension</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Module" class="help">Module:
- </a></td><td>mod_rewrite</td></tr></table></td></tr></table>
+
+</div>
+<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
+<div class="directive-section"><h2><a name="RewriteLock" id="RewriteLock">RewriteLock</a> <a name="rewritelock" id="rewritelock">Directive</a></h2>
+<table class="directive">
+<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets the name of the lock file used for RewriteMap
+synchronization</td></tr>
+<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteLock <em>file-path</em></code></td></tr>
+<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config</td></tr>
+<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
+<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
+</table>
<p>This directive sets the filename for a synchronization
- lockfile which mod_rewrite needs to communicate with <a href="#rewritemap" class="directive"><code class="directive">RewriteMap</code></a>
+ lockfile which mod_rewrite needs to communicate with <code class="directive"><a href="#rewritemap">RewriteMap</a></code>
<em>programs</em>. Set this lockfile to a local path (not on a
NFS-mounted device) when you want to use a rewriting
map-program. It is not required for other types of rewriting
maps.</p>
-<hr><h2><a name="RewriteLog">RewriteLog</a> <a name="rewritelog">Directive</a></h2><table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc"><tr><td><table bgcolor="#ffffff"><tr><td nowrap="nowrap"><strong>Description:
- </strong></td><td>Sets the name of the file used for logging rewrite engine
-processing</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Syntax" class="help">Syntax:
- </a></td><td>RewriteLog <em>file-path</em></td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Context" class="help">Context:
- </a></td><td>server config, virtual host</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Status" class="help">Status:
- </a></td><td>Extension</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Module" class="help">Module:
- </a></td><td>mod_rewrite</td></tr></table></td></tr></table>
+
+</div>
+<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
+<div class="directive-section"><h2><a name="RewriteLog" id="RewriteLog">RewriteLog</a> <a name="rewritelog" id="rewritelog">Directive</a></h2>
+<table class="directive">
+<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets the name of the file used for logging rewrite engine
+processing</td></tr>
+<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteLog <em>file-path</em></code></td></tr>
+<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
+<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
+<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
+</table>
<p>The <code class="directive">RewriteLog</code> directive sets the name
of the file to which the server logs any rewriting actions it
performs. If the name does not begin with a slash
<em>Server Root</em>. The directive should occur only once per
server config.</p>
-<blockquote><table><tr><td bgcolor="#e0e5f5"> To disable the logging of
+<div class="note"> To disable the logging of
rewriting actions it is not recommended to set
<em>Filename</em> to <code>/dev/null</code>, because
although the rewriting engine does not then output to a
to the administrator!</strong> To disable logging either
remove or comment out the <code class="directive">RewriteLog</code>
directive or use <code>RewriteLogLevel 0</code>!
-</td></tr></table></blockquote>
+</div>
-<blockquote><table><tr><td bgcolor="#e0e5f5"><p align="center"><strong>Security</strong></p>
+<div class="note"><h3>Security</h3>
See the <a href="../misc/security_tips.html">Apache Security Tips</a>
document for details on why your security could be compromised if the
directory where logfiles are stored is writable by anyone other than
the user that starts the server.
-</td></tr></table></blockquote>
+</div>
-<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><p align="center"><strong>Example</strong></p><code>
+<div class="example"><h3>Example</h3><p><code>
RewriteLog "/usr/local/var/apache/logs/rewrite.log"
-</code></td></tr></table></blockquote>
-
-<hr><h2><a name="RewriteLogLevel">RewriteLogLevel</a> <a name="rewriteloglevel">Directive</a></h2><table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc"><tr><td><table bgcolor="#ffffff"><tr><td nowrap="nowrap"><strong>Description:
- </strong></td><td>Sets the verbosity of the log file used by the rewrite
-engine</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Syntax" class="help">Syntax:
- </a></td><td>RewriteLogLevel <em>Level</em></td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Default" class="help">Default:
- </a></td><td><code>RerwiteLogLevel 0</code></td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Context" class="help">Context:
- </a></td><td>server config, virtual host</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Status" class="help">Status:
- </a></td><td>Extension</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Module" class="help">Module:
- </a></td><td>mod_rewrite</td></tr></table></td></tr></table>
+</code></p></div>
+
+
+</div>
+<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
+<div class="directive-section"><h2><a name="RewriteLogLevel" id="RewriteLogLevel">RewriteLogLevel</a> <a name="rewriteloglevel" id="rewriteloglevel">Directive</a></h2>
+<table class="directive">
+<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets the verbosity of the log file used by the rewrite
+engine</td></tr>
+<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteLogLevel <em>Level</em></code></td></tr>
+<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>RewriteLogLevel 0</code></td></tr>
+<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
+<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
+<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
+</table>
<p>The <code class="directive">RewriteLogLevel</code> directive sets the
verbosity level of the rewriting logfile. The default level 0
means no logging, while 9 or more means that practically all
<em>Level</em> to 0. This disables all rewrite action
logs.</p>
-<blockquote><table><tr><td bgcolor="#e0e5f5"> Using a high value for
+<div class="note"> Using a high value for
<em>Level</em> will slow down your Apache server
dramatically! Use the rewriting logfile at a
<em>Level</em> greater than 2 only for debugging!
-</td></tr></table></blockquote>
+</div>
-<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><p align="center"><strong>Example</strong></p><code>
+<div class="example"><h3>Example</h3><p><code>
RewriteLogLevel 3
-</code></td></tr></table></blockquote>
-
-<hr><h2><a name="RewriteMap">RewriteMap</a> <a name="rewritemap">Directive</a></h2><table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc"><tr><td><table bgcolor="#ffffff"><tr><td nowrap="nowrap"><strong>Description:
- </strong></td><td>Defines a mapping function for key-lookup</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Syntax" class="help">Syntax:
- </a></td><td>RewriteMap <em>MapName</em> <em>MapType</em>:<em>MapSource</em>
-</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Default" class="help">Default:
- </a></td><td><code>None</code></td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Context" class="help">Context:
- </a></td><td>server config, virtual host</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Status" class="help">Status:
- </a></td><td>Extension</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Module" class="help">Module:
- </a></td><td>mod_rewrite</td></tr></table></td></tr></table>
+</code></p></div>
+
+
+</div>
+<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
+<div class="directive-section"><h2><a name="RewriteMap" id="RewriteMap">RewriteMap</a> <a name="rewritemap" id="rewritemap">Directive</a></h2>
+<table class="directive">
+<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Defines a mapping function for key-lookup</td></tr>
+<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteMap <em>MapName</em> <em>MapType</em>:<em>MapSource</em>
+</code></td></tr>
+<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
+<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
+<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
+<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>The choice of different dbm types is available in
+Apache 2.0.41 and later</td></tr>
+</table>
<p>The <code class="directive">RewriteMap</code> directive defines a
<em>Rewriting Map</em> which can be used inside rule
substitution strings by the mapping-functions to
mapping-function for the substitution strings of a rewriting
rule via one of the following constructs:</p>
- <blockquote>
+ <p class="indent">
<strong><code>${</code> <em>MapName</em> <code>:</code>
- <em>LookupKey</em> <code>}</code><br>
+ <em>LookupKey</em> <code>}</code><br />
<code>${</code> <em>MapName</em> <code>:</code>
<em>LookupKey</em> <code>|</code> <em>DefaultValue</em>
<code>}</code></strong>
- </blockquote>
+ </p>
<p>When such a construct occurs the map <em>MapName</em> is
consulted and the key <em>LookupKey</em> is looked-up. If the
<ul>
<li>
- <strong>Standard Plain Text</strong><br>
+ <strong>Standard Plain Text</strong><br />
MapType: <code>txt</code>, MapSource: Unix filesystem
path to valid regular file
character) or pairs like the following - one per
line.</p>
- <blockquote>
+ <p class="indent">
<strong><em>MatchingKey</em>
<em>SubstValue</em></strong>
- </blockquote>
+ </p>
-<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><p align="center"><strong>Example</strong></p><code>
-<pre>
+<div class="example"><h3>Example</h3><pre>
##
## map.txt -- rewriting map
##
Ralf.S.Engelschall rse # Bastard Operator From Hell
Mr.Joe.Average joe # Mr. Average
-</pre>
-</code></td></tr></table></blockquote>
+</pre></div>
-<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
+<div class="example"><p><code>
RewriteMap real-to-user txt:/path/to/file/map.txt
-</code></td></tr></table></blockquote>
+</code></p></div>
</li>
<li>
- <strong>Randomized Plain Text</strong><br>
+ <strong>Randomized Plain Text</strong><br />
MapType: <code>rnd</code>, MapSource: Unix filesystem
path to valid regular file
proxy situation where the looked up values are server
names. Example:</p>
-<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
-<pre>
+<div class="example"><pre>
##
## map.txt -- rewriting map
##
static www1|www2|www3|www4
dynamic www5|www6
-</pre>
-</code></td></tr></table></blockquote>
+</pre></div>
-<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
+<div class="example"><p><code>
RewriteMap servers rnd:/path/to/file/map.txt
-</code></td></tr></table></blockquote>
+</code></p></div>
</li>
<li>
- <strong>Hash File</strong><br> MapType:
+ <strong>Hash File</strong><br /> MapType:
<code>dbm[=<em>type</em>]</code>, MapSource: Unix filesystem
path to valid regular file
in a special representation which is optimized for really
fast lookups. The <em>type</em> can be sdbm, gdbm, ndbm, or
db depending on <a href="../install.html#dbm">compile-time
- settings</a>. If the <em>type</em> is ommitted, the
+ settings</a>. If the <em>type</em> is omitted, the
compile-time default will be chosen. You can create such a
file with any DBM tool or with the following Perl
script. Be sure to adjust it to create the appropriate
type of DBM. The example creates an NDBM file.</p>
-<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
-<pre>
+<div class="example"><pre>
#!/path/to/bin/perl
##
## txt2dbm -- convert txt map to dbm format
($txtmap, $dbmmap) = @ARGV;
open(TXT, "<$txtmap") or die "Couldn't open $txtmap!\n";
-tie (%DB, 'NDBM_File', $dbmmap,O_RDWR|O_TRUNC|O_CREAT, 0644) or die "Couldn't create $dbmmap!\n";
+tie (%DB, 'NDBM_File', $dbmmap,O_RDWR|O_TRUNC|O_CREAT, 0644)
+ or die "Couldn't create $dbmmap!\n";
while (<TXT>) {
next if (/^\s*#/ or /^\s*$/);
untie %DB;
close(TXT);
-</pre>
-</code></td></tr></table></blockquote>
+</pre></div>
-<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
+<div class="example"><p><code>
$ txt2dbm map.txt map.db
-</code></td></tr></table></blockquote>
+</code></p></div>
</li>
<li>
- <strong>Internal Function</strong><br>
+ <strong>Internal Function</strong><br />
MapType: <code>int</code>, MapSource: Internal Apache
function
functions already exists:</p>
<ul>
- <li><strong>toupper</strong>:<br>
+ <li><strong>toupper</strong>:<br />
Converts the looked up key to all upper case.</li>
- <li><strong>tolower</strong>:<br>
+ <li><strong>tolower</strong>:<br />
Converts the looked up key to all lower case.</li>
- <li><strong>escape</strong>:<br>
+ <li><strong>escape</strong>:<br />
Translates special characters in the looked up key to
hex-encodings.</li>
- <li><strong>unescape</strong>:<br>
+ <li><strong>unescape</strong>:<br />
Translates hex-encodings in the looked up key back to
special characters.</li>
</ul>
</li>
<li>
- <strong>External Rewriting Program</strong><br>
+ <strong>External Rewriting Program</strong><br />
MapType: <code>prg</code>, MapSource: Unix filesystem
path to valid regular file
program which will implement a 1:1 map (<em>i.e.</em>,
key == value) could be:</p>
-<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
-<pre>
+<div class="example"><pre>
#!/usr/bin/perl
$| = 1;
while (<STDIN>) {
# ...put here any transformations or lookups...
print $_;
}
-</pre>
-</code></td></tr></table></blockquote>
+</pre></div>
<p>But be very careful:</p>
<code>stdout</code>! This will cause a deadloop! Hence
the ``<code>$|=1</code>'' in the above example...</li>
- <li>Use the <a href="#rewritelock" class="directive"><code class="directive">RewriteLock</code></a> directive to
+ <li>Use the <code class="directive"><a href="#rewritelock">RewriteLock</a></code> directive to
define a lockfile mod_rewrite can use to synchronize the
communication to the program. By default no such
synchronization takes place.</li>
per-directory context it is of course possible to
<strong>use</strong> this map in per-directory context. </p>
-<blockquote><table><tr><td bgcolor="#e0e5f5"><p align="center"><strong>Note</strong></p> For plain text and DBM format files the
+<div class="note"><h3>Note</h3> For plain text and DBM format files the
looked-up keys are cached in-core until the <code>mtime</code> of the
mapfile changes or the server does a restart. This way you can have
map-functions in rules which are used for <strong>every</strong>
request. This is no problem, because the external lookup only happens
once!
-</td></tr></table></blockquote>
-
-<hr><h2><a name="RewriteOptions">RewriteOptions</a> <a name="rewriteoptions">Directive</a></h2><table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc"><tr><td><table bgcolor="#ffffff"><tr><td nowrap="nowrap"><strong>Description:
- </strong></td><td>Sets some special options for the rewrite engine</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Syntax" class="help">Syntax:
- </a></td><td>RewriteOptions <em>Options</em></td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Default" class="help">Default:
- </a></td><td><code>None</code></td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Context" class="help">Context:
- </a></td><td>server config, virtual host, directory, .htaccess</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Status" class="help">Status:
- </a></td><td>Extension</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Module" class="help">Module:
- </a></td><td>mod_rewrite</td></tr></table></td></tr></table>
+</div>
+
+
+</div>
+<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
+<div class="directive-section"><h2><a name="RewriteOptions" id="RewriteOptions">RewriteOptions</a> <a name="rewriteoptions" id="rewriteoptions">Directive</a></h2>
+<table class="directive">
+<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets some special options for the rewrite engine</td></tr>
+<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteOptions <var>Options</var></code></td></tr>
+<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
+<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
+<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
+<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
+<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td><code>MaxRedirects</code> is no longer available in version 2.1 and
+later</td></tr>
+</table>
<p>The <code class="directive">RewriteOptions</code> directive sets some
special options for the current per-server or per-directory
- configuration. The <em>Option</em> strings can be one of the
- following:</p>
-
- <ul>
- <li>'<strong><code>inherit</code></strong>'<br>
- This forces the current configuration to inherit the
- configuration of the parent. In per-virtual-server context
- this means that the maps, conditions and rules of the main
- server are inherited. In per-directory context this means
- that conditions and rules of the parent directory's
- <code>.htaccess</code> configuration are inherited.</li>
- </ul>
-<hr><h2><a name="RewriteRule">RewriteRule</a> <a name="rewriterule">Directive</a></h2><table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc"><tr><td><table bgcolor="#ffffff"><tr><td nowrap="nowrap"><strong>Description:
- </strong></td><td>Defines rules for the rewriting engine</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Syntax" class="help">Syntax:
- </a></td><td>RewriteRule
- <em>Pattern</em> <em>Substitution</em></td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Default" class="help">Default:
- </a></td><td><code>None</code></td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Context" class="help">Context:
- </a></td><td>server config, virtual host, directory, .htaccess</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Override" class="help">Override:
- </a></td><td>FileInfo</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Status" class="help">Status:
- </a></td><td>Extension</td></tr><tr><td nowrap="nowrap"><a href="directive-dict.html#Module" class="help">Module:
- </a></td><td>mod_rewrite</td></tr></table></td></tr></table>
+ configuration. The <em>Option</em> string can be currently only one:</p>
+
+ <dl>
+ <dt><code>inherit</code></dt>
+ <dd>This forces the current configuration to inherit the
+ configuration of the parent. In per-virtual-server context
+ this means that the maps, conditions and rules of the main
+ server are inherited. In per-directory context this means
+ that conditions and rules of the parent directory's
+ <code>.htaccess</code> configuration are inherited.</dd>
+ </dl>
+
+</div>
+<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
+<div class="directive-section"><h2><a name="RewriteRule" id="RewriteRule">RewriteRule</a> <a name="rewriterule" id="rewriterule">Directive</a></h2>
+<table class="directive">
+<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Defines rules for the rewriting engine</td></tr>
+<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RewriteRule
+ <em>Pattern</em> <em>Substitution</em></code></td></tr>
+<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
+<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
+<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
+<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
+<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>
+</table>
<p>The <code class="directive">RewriteRule</code> directive is the real
rewriting workhorse. The directive can occur more than once.
Each directive then defines one single rewriting rule. The
<strong>important</strong>, because this order is used when
applying the rules at run-time.</p>
- <p><a id="patterns" name="patterns"><em>Pattern</em></a> can
- be (for Apache 1.1.x a System V8 and for Apache 1.2.x and
- later a POSIX) <a id="regexp" name="regexp">regular
+ <p><a id="patterns" name="patterns"><em>Pattern</em></a> is
+ a perl compatible <a id="regexp" name="regexp">regular
expression</a> which gets applied to the current URL. Here
``current'' means the value of the URL when this rule gets
applied. This may not be the originally requested URL,
<p>Some hints about the syntax of regular expressions:</p>
- <table bgcolor="#F0F0F0" cellspacing="0" cellpadding="5">
- <tr>
- <td>
-<pre>
+<div class="note"><pre>
<strong>Text:</strong>
<strong><code>.</code></strong> Any single character
<strong><code>[</code></strong>chars<strong><code>]</code></strong> Character class: One of chars
<strong>Escaping:</strong>
<strong><code>\</code></strong>char escape that particular char
(for instance to specify the chars "<code>.[]()</code>" <em>etc.</em>)
-</pre>
- </td>
- </tr>
- </table>
-
- <p>For more information about regular expressions either have
- a look at your local regex(3) manpage or its
- <code>src/regex/regex.3</code> copy in the Apache 1.3
- distribution. If you are interested in more detailed
+</pre></div>
+
+ <p>For more information about regular expressions have a look at the
+ perl regular expression manpage ("<a href="http://www.perldoc.com/perl5.6.1/pod/perlre.html">perldoc
+ perlre</a>"). If you are interested in more detailed
information about regular expressions and their variants
- (POSIX regex, Perl regex, <em>etc.</em>) have a look at the
+ (POSIX regex <em>etc.</em>) have a look at the
following dedicated book on this topic:</p>
- <blockquote>
- <em>Mastering Regular Expressions</em><br>
- Jeffrey E.F. Friedl<br>
- Nutshell Handbook Series<br>
- O'Reilly & Associates, Inc. 1997<br>
- ISBN 1-56592-257-3<br>
- </blockquote>
+ <p class="indent">
+ <em>Mastering Regular Expressions</em><br />
+ Jeffrey E.F. Friedl<br />
+ Nutshell Handbook Series<br />
+ O'Reilly & Associates, Inc. 1997<br />
+ ISBN 1-56592-257-3<br />
+ </p>
<p>Additionally in mod_rewrite the NOT character
('<code>!</code>') is a possible pattern prefix. This gives
it is easier to match the negative pattern, or as a last
default rule.</p>
-<blockquote><table><tr><td bgcolor="#e0e5f5"><p align="center"><strong>Notice</strong></p>
+<div class="note"><h3>Notice</h3>
When using the NOT character
to negate a pattern you cannot have grouped wildcard
parts in the pattern. This is impossible because when the
groups. In consequence, if negated patterns are used, you
cannot use <code>$N</code> in the substitution
string!
-</td></tr></table></blockquote>
+</div>
<p><a id="rhs" name="rhs"><em>Substitution</em></a> of a
rewriting rule is the string which is substituted for (or
able to have more than one pattern to be applied before a
substitution occurs.</p>
- <p>One more note: You can even create URLs in the
- substitution string containing a query string part. Just use
- a question mark inside the substitution string to indicate
- that the following stuff should be re-injected into the
- QUERY_STRING. When you want to erase an existing query
- string, end the substitution string with just the question
- mark.</p>
-
-<blockquote><table><tr><td bgcolor="#e0e5f5"><p align="center"><strong>Note</strong></p>
-There is a special feature:
+<div class="note"><h3>Query String</h3>
+ <p>The <em>Pattern</em> will not match against the query string.
+ Instead, you must use a <code class="directive"><a href="#rewritecond">RewriteCond</a></code> with the
+ <code>%{QUERY_STRING}</code> variable. You can, however, create
+ URLs in the substitution string containing a query string
+ part. Just use a question mark inside the substitution string to
+ indicate that the following stuff should be re-injected into the
+ query string. When you want to erase an existing query string,
+ end the substitution string with just the question mark. To
+ combine a new query string with an old one, use the
+ <code>[QSA]</code> flag (see below).</p>
+</div>
+
+<div class="note"><h3>Substitution of Absolute URLs</h3>
+ <p>There is a special feature:
When you prefix a substitution field with
<code>http://</code><em>thishost</em>[<em>:thisport</em>]
then <strong>mod_rewrite</strong> automatically strips it
URLs is a useful and important feature when used in
combination with a mapping-function which generates the
hostname part. Have a look at the first example in the
- example section below to understand this.
-</td></tr></table></blockquote>
+ example section below to understand this.</p>
-<blockquote><table><tr><td bgcolor="#e0e5f5"><p align="center"><strong>Remember</strong></p>
- An unconditional external
+ <p><strong>Remember:</strong> An unconditional external
redirect to your own server will not work with the prefix
<code>http://thishost</code> because of this feature. To
achieve such a self-redirect, you have to use the
- <strong>R</strong>-flag (see below).
-</td></tr></table></blockquote>
+ <strong>R</strong>-flag (see below).</p>
+</div>
<p>Additionally you can set special flags for
<em>Substitution</em> by appending</p>
- <blockquote>
+ <p class="indent">
<strong><code>[</code><em>flags</em><code>]</code></strong>
- </blockquote>
+ </p>
<p>
as the third argument to the <code>RewriteRule</code>
directive. <em>Flags</em> is a comma-separated list of the
<ul>
<li>
'<strong><code>redirect|R</code>
- [=<em>code</em>]</strong>' (force <a id="redirect" name="redirect"><strong>r</strong>edirect</a>)<br>
+ [=<em>code</em>]</strong>' (force <a id="redirect" name="redirect"><strong>r</strong>edirect</a>)<br />
Prefix <em>Substitution</em> with
<code>http://thishost[:thisport]/</code> (which makes the
new URL a URI) to force a external redirection. If no
canonicalize the URL and give it back to the client,
<em>e.g.</em>, translate ``<code>/~</code>'' into
``<code>/u/</code>'' or always append a slash to
- <code>/u/</code><em>user</em>, etc.<br>
+ <code>/u/</code><em>user</em>, etc.<br />
<p><strong>Note:</strong> When you use this flag, make
</li>
<li>'<strong><code>forbidden|F</code></strong>' (force URL
- to be <strong>f</strong>orbidden)<br>
+ to be <strong>f</strong>orbidden)<br />
This forces the current URL to be forbidden,
<em>i.e.</em>, it immediately sends back a HTTP response of
403 (FORBIDDEN). Use this flag in conjunction with
URLs.</li>
<li>'<strong><code>gone|G</code></strong>' (force URL to be
- <strong>g</strong>one)<br>
+ <strong>g</strong>one)<br />
This forces the current URL to be gone, <em>i.e.</em>, it
immediately sends back a HTTP response of 410 (GONE). Use
this flag to mark pages which no longer exist as gone.</li>
<li>
'<strong><code>proxy|P</code></strong>' (force
- <strong>p</strong>roxy)<br>
+ <strong>p</strong>roxy)<br />
This flag forces the substitution part to be internally
forced as a proxy request and immediately (<em>i.e.</em>,
rewriting rule processing stops here) put through the <a href="mod_proxy.html">proxy module</a>. You have to make
<code>mod_proxy.c</code> is part of the ``<code>httpd
-l</code>'' output. If yes, this functionality is
available to mod_rewrite. If not, then you first have to
- rebuild the ``<code>httpd</code>'' program with mod_proxy
+ rebuild the <code class="program"><a href="../programs/httpd.html">httpd</a></code> program with mod_proxy
enabled.</p>
</li>
<li>'<strong><code>last|L</code></strong>'
- (<strong>l</strong>ast rule)<br>
+ (<strong>l</strong>ast rule)<br />
Stop the rewriting process here and don't apply any more
rewriting rules. This corresponds to the Perl
<code>last</code> command or the <code>break</code> command
'<code>/e/www/</code>'.</li>
<li>'<strong><code>next|N</code></strong>'
- (<strong>n</strong>ext round)<br>
+ (<strong>n</strong>ext round)<br />
Re-run the rewriting process (starting again with the
first rewriting rule). Here the URL to match is again not
the original URL but the URL from the last rewriting rule.
This corresponds to the Perl <code>next</code> command or
the <code>continue</code> command from the C language. Use
this flag to restart the rewriting process, <em>i.e.</em>,
- to immediately go to the top of the loop.<br>
+ to immediately go to the top of the loop.<br />
<strong>But be careful not to create an infinite
loop!</strong></li>
<li>'<strong><code>chain|C</code></strong>'
- (<strong>c</strong>hained with next rule)<br>
+ (<strong>c</strong>hained with next rule)<br />
This flag chains the current rule with the next rule
(which itself can be chained with the following rule,
<em>etc.</em>). This has the following effect: if a rule
<li>
'<strong><code>type|T</code></strong>=<em>MIME-type</em>'
- (force MIME <strong>t</strong>ype)<br>
+ (force MIME <strong>t</strong>ype)<br />
Force the MIME-type of the target file to be
<em>MIME-type</em>. For instance, this can be used to
+ setup the content-type based on some conditions.
+ For example, the following snippet allows <code>.php</code> files to
+ be <em>displayed</em> by <code>mod_php</code> if they are called with
+ the <code>.phps</code> extension:
+ <div class="example"><p><code>
+ RewriteRule ^(.+\.php)s$ $1 [T=application/x-httpd-php-source]
+ </code></p></div>
+ </li>
+
+ <li>
+ '<strong><code>handler|H</code></strong>=<em>Content-handler</em>'
+ (force Content <strong>h</strong>andler)<br />
+ Force the Content-handler of the target file to be
+ <em>Content-handler</em>. For instance, this can be used to
simulate the <code>mod_alias</code> directive
<code>ScriptAlias</code> which internally forces all files
- inside the mapped directory to have a MIME type of
- ``<code>application/x-httpd-cgi</code>''.</li>
+ inside the mapped directory to have a handler of
+ ``<code>cgi-script</code>''.</li>
<li>
'<strong><code>nosubreq|NS</code></strong>' (used only if
<strong>n</strong>o internal
- <strong>s</strong>ub-request)<br>
+ <strong>s</strong>ub-request)<br />
This flag forces the rewriting engine to skip a
rewriting rule if the current request is an internal
sub-request. For instance, sub-requests occur internally
(<code>index.xxx</code>). On sub-requests it is not
always useful and even sometimes causes a failure to if
the complete set of rules are applied. Use this flag to
- exclude some rules.<br>
+ exclude some rules.<br />
<p>Use the following rule for your decision: whenever you
</li>
<li>'<strong><code>nocase|NC</code></strong>'
- (<strong>n</strong>o <strong>c</strong>ase)<br>
+ (<strong>n</strong>o <strong>c</strong>ase)<br />
This makes the <em>Pattern</em> case-insensitive,
<em>i.e.</em>, there is no difference between 'A-Z' and
'a-z' when <em>Pattern</em> is matched against the current
<li>'<strong><code>qsappend|QSA</code></strong>'
(<strong>q</strong>uery <strong>s</strong>tring
- <strong>a</strong>ppend)<br>
+ <strong>a</strong>ppend)<br />
This flag forces the rewriting engine to append a query
string part in the substitution string to the existing one
instead of replacing it. Use this when you want to add more
<li>
'<strong><code>noescape|NE</code></strong>'
(<strong>n</strong>o URI <strong>e</strong>scaping of
- output)<br>
+ output)<br />
This flag keeps mod_rewrite from applying the usual URI
escaping rules to the result of a rewrite. Ordinarily,
special characters (such as '%', '$', ';', and so on)
'%24', and '%3B', respectively); this flag prevents this
from being done. This allows percent symbols to appear in
the output, as in
-<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
+<div class="example"><p><code>
RewriteRule /foo/(.*) /bar?arg=P1\%3d$1 [R,NE]
-</code></td></tr></table></blockquote>
+</code></p></div>
which would turn '<code>/foo/zed</code>' into a safe
request for '<code>/bar?arg=P1=zed</code>'.
<li>
'<strong><code>passthrough|PT</code></strong>'
(<strong>p</strong>ass <strong>t</strong>hrough to next
- handler)<br>
+ handler)<br />
This flag forces the rewriting engine to set the
<code>uri</code> field of the internal
<code>request_rec</code> structure to the value of the
engine of <code>mod_rewrite</code> and then
<code>/def</code> to <code>/ghi</code> with
<code>mod_alias</code>:
-<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
- RewriteRule ^/abc(.*) /def$1 [PT]<br>
+<div class="example"><p><code>
+ RewriteRule ^/abc(.*) /def$1 [PT]<br />
Alias /def /ghi
-</code></td></tr></table></blockquote>
+</code></p></div>
If you omit the <code>PT</code> flag then
<code>mod_rewrite</code> will do its job fine,
<em>i.e.</em>, it rewrites <code>uri=/abc/...</code> to
URL-to-filename translators</strong>. The typical example
is the use of <code>mod_alias</code> and
<code>mod_rewrite</code>..</p>
-
-<blockquote><table><tr><td bgcolor="#e0e5f5"><p align="center"><strong>For Apache hackers</strong></p>
- If the current Apache API had a filename-to-filename
- hook additionally to the URI-to-filename hook then we
- wouldn't need this flag! But without such a hook this
- flag is the only solution. The Apache Group has
- discussed this problem and will add such a hook in
- Apache version 2.0.
-</td></tr></table></blockquote>
</li>
<li>'<strong><code>skip|S</code></strong>=<em>num</em>'
- (<strong>s</strong>kip next rule(s))<br>
+ (<strong>s</strong>kip next rule(s))<br />
This flag forces the rewriting engine to skip the next
<em>num</em> rules in sequence when the current rule
matches. Use this to make pseudo if-then-else constructs:
<li>
'<strong><code>env|E=</code></strong><em>VAR</em>:<em>VAL</em>'
- (set <strong>e</strong>nvironment variable)<br>
+ (set <strong>e</strong>nvironment variable)<br />
This forces an environment variable named <em>VAR</em> to
be set to the value <em>VAL</em>, where <em>VAL</em> can
contain regexp backreferences <code>$N</code> and
<li>
'<strong><code>cookie|CO=</code></strong><em>NAME</em>:<em>VAL</em>:<em>domain</em>[:<em>lifetime</em>[:<em>path</em>]]'
- (set <strong>co</strong>cookie)<br>
+ (set <strong>co</strong>okie)<br />
This sets a cookie on the client's browser. The cookie's name
is specified by <em>NAME</em> and the value is
<em>VAL</em>. The <em>domain</em> field is the domain of the
</ul>
-<blockquote><table><tr><td bgcolor="#e0e5f5"><p align="center"><strong>Note</strong></p> Never forget that <em>Pattern</em> is
+<div class="note"><h3>Note</h3> Never forget that <em>Pattern</em> is
applied to a complete URL in per-server configuration
files. <strong>But in per-directory configuration files, the
per-directory prefix (which always is the same for a specific
prefix will <strong>not</strong> be added and an
external redirect or proxy throughput (if flag
<strong>P</strong> is used!) is forced!</p>
-</td></tr></table></blockquote>
+</div>
-<blockquote><table><tr><td bgcolor="#e0e5f5"><p align="center"><strong>Note</strong></p>
+<div class="note"><h3>Note</h3>
To enable the rewriting engine
for per-directory configuration files you need to set
``<code>RewriteEngine On</code>'' in these files
<code>FollowSymLinks</code> for a user's directory, then
you cannot use the rewriting engine. This restriction is
needed for security reasons.
-</td></tr></table></blockquote>
+</div>
<p>Here are all possible substitution combinations and their
meanings:</p>
<p><strong>Inside per-server configuration
- (<code>httpd.conf</code>)<br>
+ (<code>httpd.conf</code>)<br />
for request ``<code>GET
- /somepath/pathinfo</code>'':</strong><br>
+ /somepath/pathinfo</code>'':</strong><br />
</p>
- <table bgcolor="#F0F0F0" cellspacing="0" cellpadding="5">
- <tr>
- <td>
-<pre>
+<div class="note"><pre>
<strong>Given Rule</strong> <strong>Resulting Substitution</strong>
---------------------------------------------- ----------------------------------
^/somepath(.*) otherpath$1 not supported, because invalid!
^/somepath(.*) http://otherhost/otherpath$1 [P] http://otherhost/otherpath/pathinfo
via internal proxy
-</pre>
- </td>
- </tr>
- </table>
+</pre></div>
<p><strong>Inside per-directory configuration for
- <code>/somepath</code><br>
+ <code>/somepath</code><br />
(<em>i.e.</em>, file <code>.htaccess</code> in dir
<code>/physical/path/to/somepath</code> containing
- <code>RewriteBase /somepath</code>)<br>
+ <code>RewriteBase /somepath</code>)<br />
for request ``<code>GET
- /somepath/localpath/pathinfo</code>'':</strong><br>
+ /somepath/localpath/pathinfo</code>'':</strong><br />
</p>
- <table bgcolor="#F0F0F0" cellspacing="0" cellpadding="5">
- <tr>
- <td>
-<pre>
+<div class="note"><pre>
<strong>Given Rule</strong> <strong>Resulting Substitution</strong>
---------------------------------------------- ----------------------------------
^localpath(.*) otherpath$1 /somepath/otherpath/pathinfo
^localpath(.*) http://otherhost/otherpath$1 [P] http://otherhost/otherpath/pathinfo
via internal proxy
-</pre>
- </td>
- </tr>
- </table>
+</pre></div>
<p><strong>Example:</strong></p>
<p>We want to rewrite URLs of the form </p>
- <blockquote>
+ <p class="indent">
<code>/</code> <em>Language</em> <code>/~</code>
<em>Realname</em> <code>/.../</code> <em>File</em>
- </blockquote>
+ </p>
<p>into </p>
- <blockquote>
+ <p class="indent">
<code>/u/</code> <em>Username</em> <code>/.../</code>
<em>File</em> <code>.</code> <em>Language</em>
- </blockquote>
+ </p>
<p>We take the rewrite mapfile from above and save it under
<code>/path/to/file/map.txt</code>. Then we only have to
add the following lines to the Apache server configuration
file:</p>
-<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
-<pre>
+<div class="example"><pre>
RewriteLog /path/to/file/rewrite.log
RewriteMap real-to-user txt:/path/to/file/map.txt
RewriteRule ^/([^/]+)/~([^/]+)/(.*)$ /u/${real-to-user:$2|nobody}/$3.$1
-</pre>
- </code></td></tr></table></blockquote>
- <hr></blockquote><h3 align="center">Apache HTTP Server Version 2.0</h3><a href="./"><img src="../images/index.gif" alt="Index"></a><a href="../"><img src="../images/home.gif" alt="Home"></a></body></html>
\ No newline at end of file
+</pre></div>
+
+</div>
+</div>
+<div class="bottomlang">
+<p><span>Available Languages: </span><a href="../en/mod/mod_rewrite.html" title="English"> en </a></p>
+</div><div id="footer">
+<p class="apache">Copyright 1999-2004 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
+<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div>
+</body></html>
\ No newline at end of file