httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From humbed...@apache.org
Subject svn commit: r1307737 - /httpd/httpd/branches/2.2.x/docs/manual/rewrite/flags.xml
Date Sat, 31 Mar 2012 08:17:05 GMT
Author: humbedooh
Date: Sat Mar 31 08:17:05 2012
New Revision: 1307737

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

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

Modified: httpd/httpd/branches/2.2.x/docs/manual/rewrite/flags.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/docs/manual/rewrite/flags.xml?rev=1307737&r1=1307736&r2=1307737&view=diff
==============================================================================
--- httpd/httpd/branches/2.2.x/docs/manual/rewrite/flags.xml (original)
+++ httpd/httpd/branches/2.2.x/docs/manual/rewrite/flags.xml Sat Mar 31 08:17:05 2012
@@ -614,10 +614,30 @@ 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 
-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>
+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>
+<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