]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Clarification of regexes/examples for rewrite flags.
authorEric Covener <covener@apache.org>
Sun, 21 Dec 2008 08:02:32 +0000 (08:02 +0000)
committerEric Covener <covener@apache.org>
Sun, 21 Dec 2008 08:02:32 +0000 (08:02 +0000)
Submitted by: Bob Ionescu
Reviewed By: covener

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@728398 13f79535-47bb-0310-9956-ffa450edef68

docs/manual/rewrite/rewrite_flags.html.en
docs/manual/rewrite/rewrite_flags.xml

index a0a0ce7fb6050492d4942241298b5e8b09b02c06..26b694f64d672d066c163da05447551c436f0895 100644 (file)
@@ -83,7 +83,7 @@ is, the entire website.</p>
 
 <div class="example"><p><code>
 RewriteEngine On<br />
-RewriteRule ^/index.html - [CO=frontdoor:yes:.apache.org:1440:/]
+RewriteRule ^/index\.html - [CO=frontdoor:yes:.apache.org:1440:/]
 </code></p></div>
 
 <p>This rule doesn't rewrite the request (the "-" rewrite target tells
@@ -161,6 +161,22 @@ The regular expression above - <code>!\.</code> - will match any request
 that does not contain the literal <code>.</code> character.
 </p>
 
+<p>This can be also used to force the handler based on some conditions.
+For example, the following snippet used in per-server context allows
+<code>.php</code> files to be <em>displayed</em> by <code>mod_php</code>
+if they are requested with the <code>.phps</code> extension:
+
+<div class="example"><p><code>
+RewriteRule ^(/source/.+\.php)s$ $1 [H=application/x-httpd-php-source]
+</code></p></div>
+</p>
+
+<p>The regular expression above - <code>^(/source/.+\.php)s$</code> - will
+match any request that starts with <code>/source/</code> followed by 1 or
+n characters followed by <code>.phps</code> literally. The backreference
+$1 referrers to the captured match within parenthesis of the regular
+expression.</p>
+
 
 <h3><a name="flag_l" id="flag_l">L|last</a></h3>
 <p>The [L] flag causes <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> to stop processing
@@ -192,7 +208,7 @@ argument to <code>index.php</code>, however, the <code class="directive"><a href
 is already for <code>index.php</code>, the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> will be skipped.</p>
 
 <div class="example"><p><code>
-RewriteCond %{REQUEST_URI} !index\.php<br />
+RewriteCond %{REQUEST_URI} !=index.php<br />
 RewriteRule ^(.*) index.php?req=$1 [L]
 </code></p></div>
 
index 334d60d3424cede9f852e0db13ac7c9ead7c1ef4..2648d5699993cbf229efe78390e8e737fb7bae99 100644 (file)
@@ -90,7 +90,7 @@ is, the entire website.</p>
 
 <example>
 RewriteEngine On<br />
-RewriteRule ^/index.html - [CO=frontdoor:yes:.apache.org:1440:/]
+RewriteRule ^/index\.html - [CO=frontdoor:yes:.apache.org:1440:/]
 </example>
 
 <p>This rule doesn't rewrite the request (the "-" rewrite target tells
@@ -168,6 +168,22 @@ RewriteRule !\. - [H=application/x-httpd-php]
 The regular expression above - <code>!\.</code> - will match any request
 that does not contain the literal <code>.</code> character.
 </p>
+
+<p>This can be also used to force the handler based on some conditions.
+For example, the following snippet used in per-server context allows
+<code>.php</code> files to be <em>displayed</em> by <code>mod_php</code>
+if they are requested with the <code>.phps</code> extension:
+
+<example>
+RewriteRule ^(/source/.+\.php)s$ $1 [H=application/x-httpd-php-source]
+</example>
+</p>
+
+<p>The regular expression above - <code>^(/source/.+\.php)s$</code> - will
+match any request that starts with <code>/source/</code> followed by 1 or
+n characters followed by <code>.phps</code> literally. The backreference
+$1 referrers to the captured match within parenthesis of the regular
+expression.</p>
 </section>
 
 <section id="flag_l"><title>L|last</title>
@@ -204,7 +220,7 @@ is already for <code>index.php</code>, the <directive
 module="mod_rewrite">RewriteRule</directive> will be skipped.</p>
 
 <example>
-RewriteCond %{REQUEST_URI} !index\.php<br />
+RewriteCond %{REQUEST_URI} !=index.php<br />
 RewriteRule ^(.*) index.php?req=$1 [L]
 </example>
 </section>