From d09a7af9aac64754f75db9ab28916f7c6c4be088 Mon Sep 17 00:00:00 2001 From: patrikj Date: Tue, 12 Mar 2002 15:22:45 +0000 Subject: [PATCH] Edited so that it can be validated. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@93856 13f79535-47bb-0310-9956-ffa450edef68 --- docs/manual/mod/mod_rewrite.xml | 148 +++++++++++++------------------- 1 file changed, 59 insertions(+), 89 deletions(-) diff --git a/docs/manual/mod/mod_rewrite.xml b/docs/manual/mod/mod_rewrite.xml index ff31e179bc..f2a2dc09cf 100644 --- a/docs/manual/mod/mod_rewrite.xml +++ b/docs/manual/mod/mod_rewrite.xml @@ -1,5 +1,5 @@ - ]> + @@ -18,24 +18,21 @@ URLs on the fly ``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.'' - + the configurability and flexibility of Sendmail.''
+ +      -- Brian Behlendorf
+      Apache Group -
- -- Brian Behlendorf
- Apache Group -
`` Despite the tons of examples and docs, mod_rewrite is voodoo. Damned cool voodoo, but still - voodoo. '' + voodoo. ''
+ +     -- Brian Moore
+      bem@news.cmc.net -
- -- Brian Moore
- bem@news.cmc.net -
@@ -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.

- -
- - - - - - - - -
[Needs graphics capability to display]
Figure 1: The - control flow through the rewriting ruleset
-
- +
+ [Needs graphics capability to display] +

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

Quoting Special Characters

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.

@@ -241,22 +226,11 @@ URLs on the fly Figure 2 shows to which locations the back-references are transfered for expansion.

-
- - - - - - - - -
[Needs graphics capability to display]
Figure 2: The - back-reference flow through a rule
-
- +
+ [Needs graphics capability to display] +

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/ - RewriteEngine - -

Enables or disables runtime rewriting engine - +Enables or disables runtime rewriting engine RewriteEngine on|off RewriteEngine off server configvirtual host @@ -391,7 +362,7 @@ processing directive or use RewriteLogLevel 0! -Security +Security See the Apache Security Tips document for details on why your security could be compromised if the @@ -688,12 +659,12 @@ while (<STDIN>) { - The RewriteMap directive can occur more than +

The RewriteMap directive can occur more than once. For each mapping-function use one RewriteMap directive to declare its rewriting mapfile. While you cannot declare a map in per-directory context it is of course possible to - use this map in per-directory context. + use this map in per-directory context.

Note For plain text and DBM format files the looked-up keys are cached in-core until the mtime of the @@ -710,7 +681,7 @@ once! RewriteBase Sets the base URL for per-directory rewrites RewriteBase URL-path -RewriteBase physical-directory-path +See usage for information. directory.htaccess FileInfo @@ -724,7 +695,7 @@ once! i.e., 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.

+ path. The default setting is; RewriteBase physical-directory-path

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.

+ implementation is correct.

@@ -877,23 +847,23 @@ Result: - - - - -
+ HTTP headers: -

HTTP_USER_AGENT
+

HTTP_USER_AGENT
HTTP_REFERER
HTTP_COOKIE
HTTP_FORWARDED
HTTP_HOST
HTTP_PROXY_CONNECTION
HTTP_ACCEPT
-

+

+ connection & request: -

REMOTE_ADDR
+

REMOTE_ADDR
REMOTE_HOST
REMOTE_USER
REMOTE_IDENT
@@ -902,28 +872,28 @@ Result: PATH_INFO
QUERY_STRING
AUTH_TYPE
-

+

+ server internals: -

DOCUMENT_ROOT
+

DOCUMENT_ROOT
SERVER_ADMIN
SERVER_NAME
SERVER_ADDR
SERVER_PORT
SERVER_PROTOCOL
SERVER_SOFTWARE
-

+

+ system stuff: -

TIME_YEAR
+

TIME_YEAR
TIME_MON
TIME_DAY
TIME_HOUR
@@ -931,18 +901,18 @@ Result: TIME_SEC
TIME_WDAY
TIME
-

+

+ specials: -

API_VERSION
+

API_VERSION
THE_REQUEST
REQUEST_URI
REQUEST_FILENAME
IS_SUBREQ
-

+

@@ -1091,7 +1061,7 @@ Result: TestString is lexically equal to CondPattern, i.e the two strings are exactly equal (character by character). If CondPattern - is just "" (two quotation marks) this + is just "" (two quotation marks) this compares TestString to the empty string.
  • '-d' (is @@ -1146,9 +1116,10 @@ Result:
    [flags]
    - as the third argument to the 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:
         .           Any single character
      @@ -1324,7 +1295,7 @@ When using the NOT character
               
    • mapping-function calls (${mapname:key|default})
    • - Back-references are $N +

      Back-references are $N (N=0..9) identifiers which will be replaced by the contents of the Nth group of the matched Pattern. The server-variables are the same @@ -1332,7 +1303,7 @@ When using the NOT character directive. The mapping-functions come from the RewriteMap directive and are explained there. These three types of variables are expanded in the order of - the above list. + the above list.

      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:

      [flags]
      +

      as the third argument to the RewriteRule directive. Flags is a comma-separated list of the - following flags: + following flags:

      • @@ -1771,7 +1743,8 @@ directory which is not always possible. / Language /~ Realname /.../ File - into + +

        into

        /u/ Username /.../ @@ -1789,10 +1762,7 @@ 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
      - - - - - + + + - -- 2.40.0