<?xml version="1.0"?>
-<!DOCTYPE xml:manual [ <!ENTITY nbsp " "> ]>
+<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.xsl"?>
<modulesynopsis>
<em>``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>
-
+ the configurability and flexibility of Sendmail.''</em><br />
+
+ -- Brian Behlendorf<br />
+ Apache Group
- <div align="RIGHT">
- -- Brian Behlendorf<br />
- Apache Group
- </div>
</blockquote>
<blockquote>
<em>`` Despite the tons of examples and docs,
mod_rewrite is voodoo. Damned cool voodoo, but still
- voodoo. ''</em>
+ voodoo. ''</em> <br />
+
+ -- Brian Moore<br />
+ bem@news.cmc.net
- <div align="RIGHT">
- -- Brian Moore<br />
- bem@news.cmc.net
- </div>
</blockquote>
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>
-
- <div align="CENTER">
- <table cellspacing="0" cellpadding="2" border="0">
- <tr>
- <td bgcolor="#CCCCCC"><img
- src="../images/mod_rewrite_fig1.gif" width="428"
- height="385"
- alt="[Needs graphics capability to display]" /></td>
- </tr>
-
- <tr>
- <td align="CENTER"><strong>Figure 1:</strong> The
- control flow through the rewriting ruleset</td>
- </tr>
- </table>
- </div>
-
+<section>
+ <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>
+</section>
<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
<section id="quoting"><title>Quoting Special Characters</title>
<p>As of Apache 1.3.20, special characters in
- <i>TestString</i> and <i>Substitution</i> strings can be
+ <em>TestString</em> and <em>Substitution</em> strings can be
escaped (that is, treated as normal characters without their
usual special meaning) by prefixing them with a slosh ('\')
character. In other words, you can include an actual
- dollar-sign character in a <i>Substitution</i> string by
+ dollar-sign character in a <em>Substitution</em> string by
using '<code>\$</code>'; this keeps mod_rewrite from trying
to treat it as a backreference.</p>
</section>
Figure 2 shows to which locations the back-references are
transfered for expansion.</p>
- <div align="CENTER">
- <table cellspacing="0" cellpadding="2" border="0">
- <tr>
- <td bgcolor="#CCCCCC"><img
- src="../images/mod_rewrite_fig2.gif" width="381"
- height="179"
- alt="[Needs graphics capability to display]" /></td>
- </tr>
-
- <tr>
- <td align="CENTER"><strong>Figure 2:</strong> The
- back-reference flow through a rule</td>
- </tr>
- </table>
- </div>
-
+<section>
+ <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>
+</section>
<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
<directivesynopsis>
-
<name>RewriteEngine</name>
-
-<summary>Enables or disables runtime rewriting engine</summary>
-
+<description>Enables or disables runtime rewriting engine</description>
<syntax>RewriteEngine on|off</syntax>
<default>RewriteEngine off</default>
<contextlist><context>server config</context><context>virtual host</context>
directive or use <code>RewriteLogLevel 0</code>!
</note>
-<note><title>Security</title>
+<note type="securitywarning"><title>Security</title>
See the <a href="../misc/security_tips.html">Apache Security Tips</a>
document for details on why your security could be compromised if the
</ol>
</li>
</ul>
- The <directive>RewriteMap</directive> directive can occur more than
+ <p>The <directive>RewriteMap</directive> directive can occur more than
once. For each mapping-function use one
<directive>RewriteMap</directive> directive to declare its rewriting
mapfile. While you cannot <strong>declare</strong> a map in
per-directory context it is of course possible to
- <strong>use</strong> this map in per-directory context.
+ <strong>use</strong> this map in per-directory context. </p>
<note><title>Note</title> For plain text and DBM format files the
looked-up keys are cached in-core until the <code>mtime</code> of the
<name>RewriteBase</name>
<description>Sets the base URL for per-directory rewrites</description>
<syntax>RewriteBase <em>URL-path</em></syntax>
-<default>RewriteBase <em>physical-directory-path</em></default>
+<default>See usage for information.</default>
<contextlist><context>directory</context><context>.htaccess</context>
</contextlist>
<override>FileInfo</override>
<em>i.e.</em>, the local directory prefix is stripped at this
stage of processing and your rewriting rules act only on the
remainder. At the end it is automatically added back to the
- path.</p>
+ path. The default setting is; <directive>RewriteBase</directive> <em>physical-directory-path</em></p>
<p>When a substitution occurs for a new URL, this module has
to re-inject the URL into the server processing. To be able
<p>The following list gives detailed information about
the internal processing steps:</p>
<pre>
-<font size="-1">Request:
+Request:
/xyz/oldstuff.html
Internal Processing:
Result:
/abc/def/newstuff.html
-</font>
</pre>
- <p><font size="-1">This seems very complicated but is
+ <p>This seems very complicated but is
the correct Apache internal processing, because the
per-directory rewriting comes too late in the
process. So, when it occurs the (rewritten) request
internally to the Apache server and the same
procedure is used by many other operations inside
Apache. So, you can be sure the design and
- implementation is correct.</font></p>
+ implementation is correct.</p>
</note>
</usage>
<table bgcolor="#F0F0F0" cellspacing="0" cellpadding="5">
<tr>
- <td valign="TOP">
+ <td>
<strong>HTTP headers:</strong>
- <p><font size="-1">HTTP_USER_AGENT<br />
+ <p>HTTP_USER_AGENT<br />
HTTP_REFERER<br />
HTTP_COOKIE<br />
HTTP_FORWARDED<br />
HTTP_HOST<br />
HTTP_PROXY_CONNECTION<br />
HTTP_ACCEPT<br />
- </font></p>
+ </p>
</td>
- <td valign="TOP">
+ <td>
<strong>connection & request:</strong>
- <p><font size="-1">REMOTE_ADDR<br />
+ <p>REMOTE_ADDR<br />
REMOTE_HOST<br />
REMOTE_USER<br />
REMOTE_IDENT<br />
PATH_INFO<br />
QUERY_STRING<br />
AUTH_TYPE<br />
- </font></p>
+ </p>
</td>
</tr>
<tr>
- <td valign="TOP">
+ <td>
<strong>server internals:</strong>
- <p><font size="-1">DOCUMENT_ROOT<br />
+ <p>DOCUMENT_ROOT<br />
SERVER_ADMIN<br />
SERVER_NAME<br />
SERVER_ADDR<br />
SERVER_PORT<br />
SERVER_PROTOCOL<br />
SERVER_SOFTWARE<br />
- </font></p>
+ </p>
</td>
- <td valign="TOP">
+ <td>
<strong>system stuff:</strong>
- <p><font size="-1">TIME_YEAR<br />
+ <p>TIME_YEAR<br />
TIME_MON<br />
TIME_DAY<br />
TIME_HOUR<br />
TIME_SEC<br />
TIME_WDAY<br />
TIME<br />
- </font></p>
+ </p>
</td>
- <td valign="TOP">
+ <td>
<strong>specials:</strong>
- <p><font size="-1">API_VERSION<br />
+ <p>API_VERSION<br />
THE_REQUEST<br />
REQUEST_URI<br />
REQUEST_FILENAME<br />
IS_SUBREQ<br />
- </font></p>
+ </p>
</td>
</tr>
</table>
<em>TestString</em> is lexically equal to
<em>CondPattern</em>, i.e the two strings are exactly
equal (character by character). If <em>CondPattern</em>
- is just <samp>""</samp> (two quotation marks) this
+ is just <code>""</code> (two quotation marks) this
compares <em>TestString</em> to the empty string.</li>
<li>'<strong>-d</strong>' (is
<blockquote>
<strong><code>[</code><em>flags</em><code>]</code></strong>
</blockquote>
- as the third argument to the <code>RewriteCond</code>
+
+ <p>as the third argument to the <code>RewriteCond</code>
directive. <em>Flags</em> is a comma-separated list of the
- following flags:
+ following flags:</p>
<ul>
<li>'<strong><code>nocase|NC</code></strong>'
<table bgcolor="#F0F0F0" cellspacing="0" cellpadding="5">
<tr>
- <td valign="TOP">
+ <td>
<pre>
<strong>Text:</strong>
<strong><code>.</code></strong> Any single character
<li><a href="#mapfunc">mapping-function</a> calls
(<code>${mapname:key|default}</code>)</li>
</ol>
- Back-references are <code>$</code><strong>N</strong>
+ <p>Back-references are <code>$</code><strong>N</strong>
(<strong>N</strong>=0..9) identifiers which will be replaced
by the contents of the <strong>N</strong>th group of the
matched <em>Pattern</em>. The server-variables are the same
directive. The mapping-functions come from the
<code>RewriteMap</code> directive and are explained there.
These three types of variables are expanded in the order of
- the above list.
+ the above list. </p>
<p>As already mentioned above, all the rewriting rules are
applied to the <em>Substitution</em> (in the order of
<blockquote>
<strong><code>[</code><em>flags</em><code>]</code></strong>
</blockquote>
+ <p>
as the third argument to the <code>RewriteRule</code>
directive. <em>Flags</em> is a comma-separated list of the
- following flags:
+ following flags: </p>
<ul>
<li>
<code>/</code> <em>Language</em> <code>/~</code>
<em>Realname</em> <code>/.../</code> <em>File</em>
</blockquote>
- into
+
+ <p>into </p>
<blockquote>
<code>/u/</code> <em>Username</em> <code>/.../</code>
RewriteMap real-to-user txt:/path/to/file/map.txt
RewriteRule ^/([^/]+)/~([^/]+)/(.*)$ /u/${real-to-user:$2|nobody}/$3.$1
</pre>
-</example>
-
-</usage>
-</directivesynopsis>
-
+ </example>
+ </usage>
+ </directivesynopsis>
</modulesynopsis>
-