You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by hu...@apache.org on 2012/03/31 10:12:28 UTC

svn commit: r1307735 - /httpd/httpd/branches/2.4.x/docs/manual/rewrite/flags.xml

Author: humbedooh
Date: Sat Mar 31 08:12:28 2012
New Revision: 1307735

URL: http://svn.apache.org/viewvc?rev=1307735&view=rev
Log:
Merge r1307733 from trunk:

Clarify the [Skip] flag and add an if-then-else example

Modified:
    httpd/httpd/branches/2.4.x/docs/manual/rewrite/flags.xml

Modified: httpd/httpd/branches/2.4.x/docs/manual/rewrite/flags.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/docs/manual/rewrite/flags.xml?rev=1307735&r1=1307734&r2=1307735&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/docs/manual/rewrite/flags.xml (original)
+++ httpd/httpd/branches/2.4.x/docs/manual/rewrite/flags.xml Sat Mar 31 08:12:28 2012
@@ -661,10 +661,31 @@ module="mod_rewrite">RewriteCond</direct
 <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. So, you can
+negate those conditions and add a <code>RewriteRule</code> with a [Skip] flag. You can
 use this to make pseudo if-then-else constructs: The last rule of
 the then-clause becomes <code>skip=N</code>, where N is the
-number of rules in the else-clause.</p>
+number of rules in the else-clause:</p>
+<example>
+# Does the file exist?<br />
+RewriteCond %{REQUEST_FILENAME} !-f<br />
+RewriteCond %{REQUEST_FILENAME} !-d<br />
+# Create an if-then-else construct by skipping 3 lines if we meant to go to the &quot;else&quot; stanza.<br />
+RewriteRule .? - [S=3]<br />
+<br />
+# IF the file exists, then:
+<indent>
+	RewriteRule (.*\.gif) images.php?$1<br />
+	RewriteRule (.*\.html) docs.php?$1<br />
+	# Skip past the &quot;else&quot; stanza.<br />
+	RewriteRule .? - [S=1]<br />
+</indent>
+# ELSE...
+<indent>
+	RewriteRule (.*) 404.php?file=$1<br />
+</indent>
+# END
+</example>
+
 </section>
 
 <section id="flag_t"><title>T|type</title>