httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From humbed...@apache.org
Subject svn commit: r1307733 - /httpd/httpd/trunk/docs/manual/rewrite/flags.xml
Date Sat, 31 Mar 2012 08:10:36 GMT
Author: humbedooh
Date: Sat Mar 31 08:10:35 2012
New Revision: 1307733

URL: http://svn.apache.org/viewvc?rev=1307733&view=rev
Log:
Clarify the [Skip] flag and add an if-then-else example

Modified:
    httpd/httpd/trunk/docs/manual/rewrite/flags.xml

Modified: httpd/httpd/trunk/docs/manual/rewrite/flags.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/rewrite/flags.xml?rev=1307733&r1=1307732&r2=1307733&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/rewrite/flags.xml (original)
+++ httpd/httpd/trunk/docs/manual/rewrite/flags.xml Sat Mar 31 08:10:35 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>



Mime
View raw message