From 5fd456f6dfc78e4b465c666ed5de89d92b41cdae Mon Sep 17 00:00:00 2001 From: Rich Bowen Date: Wed, 12 Jul 2006 01:24:35 +0000 Subject: [PATCH] Adds more discussion of several rewrite flags. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@421068 13f79535-47bb-0310-9956-ffa450edef68 --- docs/manual/rewrite/flags.html.en | 50 +++++++++++++++++++-- docs/manual/rewrite/flags.xml | 53 +++++++++++++++++++++-- docs/manual/rewrite/rewrite_intro.html.en | 18 ++++++-- docs/manual/rewrite/rewrite_intro.xml | 21 +++++++-- 4 files changed, 130 insertions(+), 12 deletions(-) diff --git a/docs/manual/rewrite/flags.html.en b/docs/manual/rewrite/flags.html.en index 4e2510e691..25d271594f 100644 --- a/docs/manual/rewrite/flags.html.en +++ b/docs/manual/rewrite/flags.html.en @@ -114,7 +114,21 @@ an example, not as a recommendation.

F|forbidden

-

Forbidden flag

+

Using the [F] flag causes Apache to return a 403 Forbidden status +code to the client. While the same behavior can be accomplished using +the Deny directive, this +allows more flexibility in assigning a Forbidden status.

+ +

The following rule will forbid .exe files from being +downloaded from your server.

+ +

+RewriteRule \.exe - [F] +

+ +

This rule uses the "-" syntax for the rewrite target, which means +that the requested URI is not modified.

+

G|gone

@@ -134,7 +148,18 @@ an example, not as a recommendation.

NC|nocase

-

No case flag

+

Use of the [NC] flag causes the RewriteRule to be matched in a +case-insensitive manner. That is, it doesn't care whether letters appear +as upper-case or lower-case in the matched URI.

+ +

In the example below, any request for an image file will be proxied +to your dedicated image server. The match is case-insensitive, so that +.jpg and .JPG files are both acceptable, for +example.

+ +

+RewriteRule (.*\.(jpg|gif|png))$ http://images.example.com$1 [P,NC] +

NE|noescape

@@ -166,7 +191,26 @@ an example, not as a recommendation.

S|skip

-

Skip flag

+

The [S] flag is used to skip rules that you don't want to run. This +can be thought of as a goto statement in your rewrite +ruleset. In the following example, we only want to run the RewriteRule if the requested URI +doesn't correspond with an actual file.

+ +

+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteCond %{REQUEST_FILENAME} !-d
+RewriteRule .? - [S=2]
+
+RewriteRule (.*\.gif) images.php?$1
+RewriteRule (.*\.html) docs.php?$1 +

+ +

This technique is useful because a RewriteCond only applies to the +RewriteRule immediately +following it. Thus, if you want to make a RewriteCond apply +to several RewriteRules, one possible technique is to +negate those conditions and use a [Skip] flag.

+

T|type

diff --git a/docs/manual/rewrite/flags.xml b/docs/manual/rewrite/flags.xml index a2439be07e..c07ead949d 100644 --- a/docs/manual/rewrite/flags.xml +++ b/docs/manual/rewrite/flags.xml @@ -122,7 +122,21 @@ an example, not as a recommendation.

F|forbidden -

Forbidden flag

+

Using the [F] flag causes Apache to return a 403 Forbidden status +code to the client. While the same behavior can be accomplished using +the Deny directive, this +allows more flexibility in assigning a Forbidden status.

+ +

The following rule will forbid .exe files from being +downloaded from your server.

+ + +RewriteRule \.exe - [F] + + +

This rule uses the "-" syntax for the rewrite target, which means +that the requested URI is not modified.

+
G|gone @@ -142,7 +156,19 @@ an example, not as a recommendation.

NC|nocase -

No case flag

+

Use of the [NC] flag causes the RewriteRule to be matched in a +case-insensitive manner. That is, it doesn't care whether letters appear +as upper-case or lower-case in the matched URI.

+ +

In the example below, any request for an image file will be proxied +to your dedicated image server. The match is case-insensitive, so that +.jpg and .JPG files are both acceptable, for +example.

+ + +RewriteRule (.*\.(jpg|gif|png))$ http://images.example.com$1 [P,NC] +
NE|noescape @@ -174,7 +200,28 @@ an example, not as a recommendation.

S|skip -

Skip flag

+

The [S] flag is used to skip rules that you don't want to run. This +can be thought of as a goto statement in your rewrite +ruleset. In the following example, we only want to run the RewriteRule if the requested URI +doesn't correspond with an actual file.

+ + +RewriteCond %{REQUEST_FILENAME} !-f
+RewriteCond %{REQUEST_FILENAME} !-d
+RewriteRule .? - [S=2]
+
+RewriteRule (.*\.gif) images.php?$1
+RewriteRule (.*\.html) docs.php?$1 +
+ +

This technique is useful because a RewriteCond only applies to the +RewriteRule immediately +following it. Thus, if you want to make a RewriteCond apply +to several RewriteRules, one possible technique is to +negate those conditions and use a [Skip] flag.

+
T|type diff --git a/docs/manual/rewrite/rewrite_intro.html.en b/docs/manual/rewrite/rewrite_intro.html.en index f08e8c94fd..184b4e8430 100644 --- a/docs/manual/rewrite/rewrite_intro.html.en +++ b/docs/manual/rewrite/rewrite_intro.html.en @@ -145,13 +145,25 @@ examples.
top

Rewrite Flags

-

Discussion of the flags to RewriteRule, and when and why one might -use them.

+

The behavior of a RewriteRule can be modified by the +application of one more flags to the end of the rule. For example, the +matching behavior of a rule can be made case-insensitive by the +application of the [NC] flag: +

+

+RewriteRule ^puppy.html smalldog.html [NC] +

+ +

For more details on the available flags, their meanings, and +examples, see the Rewrite Flags document.

+
top

Rewrite conditions

-

Discussion of RewriteCond, looping, and other related concepts. +

The RewriteCond directive +allows a condition to be applied to a RewriteRule.

+
top

Rewrite maps

diff --git a/docs/manual/rewrite/rewrite_intro.xml b/docs/manual/rewrite/rewrite_intro.xml index c757a4908d..0a206bdb83 100644 --- a/docs/manual/rewrite/rewrite_intro.xml +++ b/docs/manual/rewrite/rewrite_intro.xml @@ -148,13 +148,28 @@ examples.
Rewrite Flags -

Discussion of the flags to RewriteRule, and when and why one might -use them.

+

The behavior of a RewriteRule can be modified by the +application of one more flags to the end of the rule. For example, the +matching behavior of a rule can be made case-insensitive by the +application of the [NC] flag: +

+ +RewriteRule ^puppy.html smalldog.html [NC] + + +

For more details on the available flags, their meanings, and +examples, see the Rewrite Flags document.

+
+
Rewrite conditions -

Discussion of RewriteCond, looping, and other related concepts. +

The RewriteCond directive +allows a condition to be applied to a RewriteRule.

+
Rewrite maps -- 2.40.0