From: Eric Covener Date: Wed, 5 Jan 2011 22:39:47 +0000 (+0000) Subject: PR#44838: be more up front with how the per-dir RewriteRule comparison is X-Git-Tag: 2.3.11~266 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7f6e27420f8106d5835e64ad785bc775d4c47a2e;p=apache PR#44838: be more up front with how the per-dir RewriteRule comparison is the filesystem path minus the Directory the rules were listed in. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1055671 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/mod/mod_rewrite.xml b/docs/manual/mod/mod_rewrite.xml index f13fe66189..08060c9b89 100644 --- a/docs/manual/mod/mod_rewrite.xml +++ b/docs/manual/mod/mod_rewrite.xml @@ -879,24 +879,59 @@ RewriteRule ^/$ /homepage.std.html [L] RewriteRule.

What is matched? -

The Pattern will initially be matched against the part of the - URL after the hostname and port, and before the query string.

- -

When the RewriteRule appears in per-directory (htaccess) context, the - Pattern is matched against what remains of the URL after removing - the prefix that lead Apache httpd to the current rules (see the - RewriteBase). The removed prefix - always ends with a slash, meaning the matching occurs against a string which - never has a leading slash. A Pattern with ^/ never - matches in per-directory context.

- +

In VirtualHost context, + The Pattern will initially be matched against the part of the + URL after the hostname and port, and before the query string (e.g. "/app1/index.html").

+ +

In Directory and htaccess context, + the Pattern will initially be matched against the + filesystem path, after removing the prefix that lead the server + to the current RewriteRule (e.g. "app1/index.html" + or "index.html" depending on where the directives are defined).

+

If you wish to match against the hostname, port, or query string, use a RewriteCond with the %{HTTP_HOST}, %{SERVER_PORT}, or - %{QUERY_STRING} variables respectively. If you wish to - match against the full URL-path in a per-directory (htaccess) RewriteRule, - use the %{REQUEST_URI} variable.

+ %{QUERY_STRING} variables respectively.

+ +
+Per-directory Rewrites +

For some hints on regular @@ -1171,44 +1206,6 @@ flag is used on the RewriteRule directive.

-Per-directory Rewrites - -

The rewrite engine may be used in .htaccess files. To enable the -rewrite engine for these files you need to set -"RewriteEngine On" and -"Options FollowSymLinks" must be enabled. If your -administrator has disabled override of FollowSymLinks for -a user's directory, then you cannot use the rewrite engine. This -restriction is required for security reasons.

- -

When using the rewrite engine in .htaccess files the -per-directory prefix (which always is the same for a specific -directory) is automatically removed for the pattern matching -and automatically added after the substitution has been -done. This feature is essential for many sorts of rewriting; without -this, you would always have to match the parent directory, which is -not always possible. There is one exception: If a substitution string -starts with http://, then the directory prefix will -not be added, and an external redirect (or proxy -throughput, if using flag P) is forced. See the -RewriteBase directive for -more information.

- -

The rewrite engine may also be used in Directory sections with the same -prefix-matching rules as would be applied to .htaccess -files. It is usually simpler, however, to avoid the prefix substitution -complication by putting the rewrite rules in the main server or -virtual host context, rather than in a Directory section.

- -

Although rewrite rules are syntactically permitted in Location and Files sections, this -should never be necessary and is unsupported.

- -

Here are all possible substitution combinations and their meanings: