]> granicus.if.org Git - apache/commitdiff
Adds more discussion of several rewrite flags.
authorRich Bowen <rbowen@apache.org>
Wed, 12 Jul 2006 01:24:35 +0000 (01:24 +0000)
committerRich Bowen <rbowen@apache.org>
Wed, 12 Jul 2006 01:24:35 +0000 (01:24 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@421068 13f79535-47bb-0310-9956-ffa450edef68

docs/manual/rewrite/flags.html.en
docs/manual/rewrite/flags.xml
docs/manual/rewrite/rewrite_intro.html.en
docs/manual/rewrite/rewrite_intro.xml

index 4e2510e6913ab1b9981a1d9d09d7fd6c144123a7..25d271594f27b274634a127ec62336ad6e3046bb 100644 (file)
@@ -114,7 +114,21 @@ an example, not as a recommendation.</p>
 
 
 <h3><a name="flag_f" id="flag_f">F|forbidden</a></h3>
-<p>Forbidden flag</p>
+<p>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 <code class="directive"><a href="../mod/mod_access.html#deny">Deny</a></code> directive, this 
+allows more flexibility in assigning a Forbidden status.</p>
+
+<p>The following rule will forbid <code>.exe</code> files from being
+downloaded from your server.</p>
+
+<div class="example"><p><code>
+RewriteRule \.exe - [F]
+</code></p></div>
+
+<p>This rule uses the "-" syntax for the rewrite target, which means
+that the requested URI is not modified.</p>
+
 
 
 <h3><a name="flag_g" id="flag_g">G|gone</a></h3>
@@ -134,7 +148,18 @@ an example, not as a recommendation.</p>
 
 
 <h3><a name="flag_nc" id="flag_nc">NC|nocase</a></h3>
-<p>No case flag</p>
+<p>Use of the [NC] flag causes the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> 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.</p>
+
+<p>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
+<code>.jpg</code> and <code>.JPG</code> files are both acceptable, for
+example.</p>
+
+<div class="example"><p><code>
+RewriteRule (.*\.(jpg|gif|png))$ http://images.example.com$1 [P,NC]
+</code></p></div>
 
 
 <h3><a name="flag_ne" id="flag_ne">NE|noescape</a></h3>
@@ -166,7 +191,26 @@ an example, not as a recommendation.</p>
 
 
 <h3><a name="flag_s" id="flag_s">S|skip</a></h3>
-<p>Skip flag</p>
+<p>The [S] flag is used to skip rules that you don't want to run. This
+can be thought of as a <code>goto</code> statement in your rewrite
+ruleset. In the following example, we only want to run the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> if the requested URI
+doesn't correspond with an actual file.</p>
+
+<div class="example"><p><code>
+RewriteCond %{REQUEST_FILENAME} !-f<br />
+RewriteCond %{REQUEST_FILENAME} !-d<br />
+RewriteRule .? - [S=2]<br />
+<br />
+RewriteRule (.*\.gif) images.php?$1<br />
+RewriteRule (.*\.html) docs.php?$1
+</code></p></div>
+
+<p>This technique is useful because a <code class="directive"><a href="../mod/mod_rewrite.html#rewritecond">RewriteCond</a></code> only applies to the
+<code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> immediately
+following it. Thus, if you want to make a <code>RewriteCond</code> apply
+to several <code>RewriteRule</code>s, one possible technique is to
+negate those conditions and use a [Skip] flag.</p>
+
 
 
 <h3><a name="flag_t" id="flag_t">T|type</a></h3>
index a2439be07eca77c09f6bb8db154a3a6aa1be727e..c07ead949db55dd55fb31397a7198aef200324b3 100644 (file)
@@ -122,7 +122,21 @@ an example, not as a recommendation.</p>
 </section>
 
 <section id="flag_f"><title>F|forbidden</title>
-<p>Forbidden flag</p>
+<p>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 <directive module="mod_access">Deny</directive> directive, this 
+allows more flexibility in assigning a Forbidden status.</p>
+
+<p>The following rule will forbid <code>.exe</code> files from being
+downloaded from your server.</p>
+
+<example>
+RewriteRule \.exe - [F]
+</example>
+
+<p>This rule uses the "-" syntax for the rewrite target, which means
+that the requested URI is not modified.</p>
+
 </section>
 
 <section id="flag_g"><title>G|gone</title>
@@ -142,7 +156,19 @@ an example, not as a recommendation.</p>
 </section>
 
 <section id="flag_nc"><title>NC|nocase</title>
-<p>No case flag</p>
+<p>Use of the [NC] flag causes the <directive
+module="mod_rewrite">RewriteRule</directive> 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.</p>
+
+<p>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
+<code>.jpg</code> and <code>.JPG</code> files are both acceptable, for
+example.</p>
+
+<example>
+RewriteRule (.*\.(jpg|gif|png))$ http://images.example.com$1 [P,NC]
+</example>
 </section>
 
 <section id="flag_ne"><title>NE|noescape</title>
@@ -174,7 +200,28 @@ an example, not as a recommendation.</p>
 </section>
 
 <section id="flag_s"><title>S|skip</title>
-<p>Skip flag</p>
+<p>The [S] flag is used to skip rules that you don't want to run. This
+can be thought of as a <code>goto</code> statement in your rewrite
+ruleset. In the following example, we only want to run the <directive
+module="mod_rewrite">RewriteRule</directive> if the requested URI
+doesn't correspond with an actual file.</p>
+
+<example>
+RewriteCond %{REQUEST_FILENAME} !-f<br />
+RewriteCond %{REQUEST_FILENAME} !-d<br />
+RewriteRule .? - [S=2]<br />
+<br />
+RewriteRule (.*\.gif) images.php?$1<br />
+RewriteRule (.*\.html) docs.php?$1
+</example>
+
+<p>This technique is useful because a <directive
+module="mod_rewrite">RewriteCond</directive> only applies to the
+<directive module="mod_rewrite">RewriteRule</directive> immediately
+following it. Thus, if you want to make a <code>RewriteCond</code> apply
+to several <code>RewriteRule</code>s, one possible technique is to
+negate those conditions and use a [Skip] flag.</p>
+
 </section>
 
 <section id="flag_t"><title>T|type</title>
index f08e8c94fd706f1765c03ee818bd7672989f3f55..184b4e8430ab712609eb7a1ff80237535639c7f6 100644 (file)
@@ -145,13 +145,25 @@ examples.
 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
 <h2><a name="flags" id="flags">Rewrite Flags</a></h2>
-<p>Discussion of the flags to RewriteRule, and when and why one might
-use them.</p>
+<p>The behavior of a <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> 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 <code>[NC]</code> flag:
+</p>
+<div class="example"><p><code>
+RewriteRule ^puppy.html smalldog.html [NC]
+</code></p></div>
+
+<p>For more details on the available flags, their meanings, and
+examples, see the <a href="flags.html">Rewrite Flags</a> document.</p>
+
 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
 <h2><a name="rewritecond" id="rewritecond">Rewrite conditions</a></h2>
-<p>Discussion of RewriteCond, looping, and other related concepts.
+<p>The <code class="directive"><a href="../mod/mod_rewrite.html#rewritecond">RewriteCond</a></code> directive
+allows a condition to be applied to a <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code>.
 </p>
+
 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
 <div class="section">
 <h2><a name="rewritemap" id="rewritemap">Rewrite maps</a></h2>
index c757a4908d5d201e080c8eb124ab56dbdaecc69b..0a206bdb83034a4382ae70c9b61324f7670a9c92 100644 (file)
@@ -148,13 +148,28 @@ examples.
 </section>
 
 <section id="flags"><title>Rewrite Flags</title>
-<p>Discussion of the flags to RewriteRule, and when and why one might
-use them.</p>
+<p>The behavior of a <directive
+module="mod_rewrite">RewriteRule</directive> 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 <code>[NC]</code> flag:
+</p>
+<example>
+RewriteRule ^puppy.html smalldog.html [NC]
+</example>
+
+<p>For more details on the available flags, their meanings, and
+examples, see the <a href="flags.html">Rewrite Flags</a> document.</p>
+
 </section>
 
+
 <section id="rewritecond"><title>Rewrite conditions</title>
-<p>Discussion of RewriteCond, looping, and other related concepts.
+<p>The <directive module="mod_rewrite">RewriteCond</directive> directive
+allows a condition to be applied to a <directive
+module="mod_rewrite">RewriteRule</directive>.
 </p>
+
 </section>
 
 <section id="rewritemap"><title>Rewrite maps</title>