From 5fd456f6dfc78e4b465c666ed5de89d92b41cdae Mon Sep 17 00:00:00 2001
From: Rich Bowen
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.
+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]
+
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 RewriteRule
s, one possible technique is to
+negate those conditions and use a [Skip] flag.
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
The following rule will forbid .exe
files from being
+downloaded from your server.
This rule uses the "-" syntax for the rewrite target, which means +that the requested URI is not modified.
+No case flag
+Use of the [NC] flag causes the
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.
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
This technique is useful because a RewriteCond
apply
+to several RewriteRule
s, one possible technique is to
+negate those conditions and use a [Skip] flag.
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.
+Discussion of RewriteCond, looping, and other related concepts. +
The RewriteCond
directive
+allows a condition to be applied to a RewriteRule
.
Discussion of the flags to RewriteRule, and when and why one might -use them.
+The behavior of a [NC]
flag:
+
For more details on the available flags, their meanings, and +examples, see the Rewrite Flags document.
+Discussion of RewriteCond, looping, and other related concepts. +
The