From: Daniel Gruno Date: Sat, 31 Mar 2012 08:12:28 +0000 (+0000) Subject: Merge r1307733 from trunk: X-Git-Tag: 2.4.2~56 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=93433aae3f96edae025d24171cb475734e48032d;p=apache Merge r1307733 from trunk: Clarify the [Skip] flag and add an if-then-else example git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1307735 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/rewrite/flags.xml b/docs/manual/rewrite/flags.xml index c2ae0a0df8..136a020cfd 100644 --- a/docs/manual/rewrite/flags.xml +++ b/docs/manual/rewrite/flags.xml @@ -661,10 +661,31 @@ module="mod_rewrite">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. So, you can +negate those conditions and add a RewriteRule with a [Skip] flag. You can use this to make pseudo if-then-else constructs: The last rule of the then-clause becomes skip=N, where N is the -number of rules in the else-clause.

+number of rules in the else-clause:

+ +# Does the file exist?
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteCond %{REQUEST_FILENAME} !-d
+# Create an if-then-else construct by skipping 3 lines if we meant to go to the "else" stanza.
+RewriteRule .? - [S=3]
+
+# IF the file exists, then: + + RewriteRule (.*\.gif) images.php?$1
+ RewriteRule (.*\.html) docs.php?$1
+ # Skip past the "else" stanza.
+ RewriteRule .? - [S=1]
+
+# ELSE... + + RewriteRule (.*) 404.php?file=$1
+
+# END +
+
T|type