From: Eric Covener Date: Sun, 21 Dec 2008 08:02:32 +0000 (+0000) Subject: Clarification of regexes/examples for rewrite flags. X-Git-Tag: 2.3.1~99 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b7bb200334bf781cd895d679e538f96f7eb3ddc6;p=thirdparty%2Fapache%2Fhttpd.git Clarification of regexes/examples for rewrite flags. 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 --- diff --git a/docs/manual/rewrite/rewrite_flags.html.en b/docs/manual/rewrite/rewrite_flags.html.en index a0a0ce7fb60..26b694f64d6 100644 --- a/docs/manual/rewrite/rewrite_flags.html.en +++ b/docs/manual/rewrite/rewrite_flags.html.en @@ -83,7 +83,7 @@ is, the entire website.

RewriteEngine On
-RewriteRule ^/index.html - [CO=frontdoor:yes:.apache.org:1440:/] +RewriteRule ^/index\.html - [CO=frontdoor:yes:.apache.org:1440:/]

This rule doesn't rewrite the request (the "-" rewrite target tells @@ -161,6 +161,22 @@ The regular expression above - !\. - will match any request that does not contain the literal . character.

+

This can be also used to force the handler based on some conditions. +For example, the following snippet used in per-server context allows +.php files to be displayed by mod_php +if they are requested with the .phps extension: + +

+RewriteRule ^(/source/.+\.php)s$ $1 [H=application/x-httpd-php-source] +

+

+ +

The regular expression above - ^(/source/.+\.php)s$ - will +match any request that starts with /source/ followed by 1 or +n characters followed by .phps literally. The backreference +$1 referrers to the captured match within parenthesis of the regular +expression.

+

L|last

The [L] flag causes mod_rewrite to stop processing @@ -192,7 +208,7 @@ argument to index.php, however, the index.php, the RewriteRule will be skipped.

-RewriteCond %{REQUEST_URI} !index\.php
+RewriteCond %{REQUEST_URI} !=index.php
RewriteRule ^(.*) index.php?req=$1 [L]

diff --git a/docs/manual/rewrite/rewrite_flags.xml b/docs/manual/rewrite/rewrite_flags.xml index 334d60d3424..2648d569999 100644 --- a/docs/manual/rewrite/rewrite_flags.xml +++ b/docs/manual/rewrite/rewrite_flags.xml @@ -90,7 +90,7 @@ is, the entire website.

RewriteEngine On
-RewriteRule ^/index.html - [CO=frontdoor:yes:.apache.org:1440:/] +RewriteRule ^/index\.html - [CO=frontdoor:yes:.apache.org:1440:/]

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 - !\. - will match any request that does not contain the literal . character.

+ +

This can be also used to force the handler based on some conditions. +For example, the following snippet used in per-server context allows +.php files to be displayed by mod_php +if they are requested with the .phps extension: + + +RewriteRule ^(/source/.+\.php)s$ $1 [H=application/x-httpd-php-source] + +

+ +

The regular expression above - ^(/source/.+\.php)s$ - will +match any request that starts with /source/ followed by 1 or +n characters followed by .phps literally. The backreference +$1 referrers to the captured match within parenthesis of the regular +expression.

L|last @@ -204,7 +220,7 @@ is already for index.php, the RewriteRule will be skipped.

-RewriteCond %{REQUEST_URI} !index\.php
+RewriteCond %{REQUEST_URI} !=index.php
RewriteRule ^(.*) index.php?req=$1 [L]