From: patrikj
+
+ -- Brian Behlendorf
+ Apache Group
-
- Apache Group
-
`` Despite the tons of examples and docs,
mod_rewrite is voodoo. Damned cool voodoo, but still
- voodoo. ''
+ voodoo. ''
@@ -178,23 +175,11 @@ URLs on the fly
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.
+
+ -- Brian Moore
+ bem@news.cmc.net
-
- bem@news.cmc.net
-
- |
Figure 1: The - control flow through the rewriting ruleset | -
Figure 1:The control flow through the rewriting ruleset
+As you can see, first the URL is matched against the
Pattern of each rule. When it fails mod_rewrite
immediately stops processing this rule and continues with the
@@ -221,11 +206,11 @@ URLs on the fly
As of Apache 1.3.20, special characters in
- TestString and Substitution strings can be
+ TestString and Substitution 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 Substitution string by
+ dollar-sign character in a Substitution string by
using '\$
'; this keeps mod_rewrite from trying
to treat it as a backreference.
- |
Figure 2: The - back-reference flow through a rule | -
Figure 2: The back-reference flow through a rule.
+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
@@ -305,11 +279,8 @@ SCRIPT_URI=http://en1.engelschall.com/u/rse/
The RewriteLogLevel 0
!
-mtime
of the
@@ -710,7 +681,7 @@ once!
When a substitution occurs for a new URL, this module has to re-inject the URL into the server processing. To be able @@ -772,7 +743,7 @@ RewriteRule ^oldstuff\.html$ newstuff.html
The following list gives detailed information about the internal processing steps:
-Request: +Request: /xyz/oldstuff.html Internal Processing: @@ -783,9 +754,8 @@ Internal Processing: Result: /abc/def/newstuff.html --
This seems very complicated but is
+ 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
@@ -795,7 +765,7 @@ Result:
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.
+ |
HTTP headers:
- HTTP_USER_AGENT HTTP_USER_AGENT |
- + |
connection & request:
- REMOTE_ADDR REMOTE_ADDR |
||
+ |
server internals:
- DOCUMENT_ROOT DOCUMENT_ROOT |
- + |
system stuff:
- TIME_YEAR TIME_YEAR |
- + |
specials:
- API_VERSION API_VERSION |
""
(two quotation marks) this
compares TestString to the empty string.
- as the third argument to the[
flags]
RewriteCond
+
+ as the third argument to the RewriteCond
directive. Flags is a comma-separated list of the
- following flags:
+ following flags:
nocase|NC
'
@@ -1241,7 +1212,7 @@ RewriteRule ^/$ /homepage.std.html [L]
+ |
Text:
${mapname:key|default} )$ N
+ Back-references are As already mentioned above, all the rewriting rules are applied to the Substitution (in the order of @@ -1385,9 +1356,10 @@ There is a special feature: +
as the third argument to the
|