Return-Path: Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: (qmail 92095 invoked from network); 6 Jan 2011 01:12:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 6 Jan 2011 01:12:02 -0000 Received: (qmail 80856 invoked by uid 500); 6 Jan 2011 01:12:02 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 80801 invoked by uid 500); 6 Jan 2011 01:12:02 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 80794 invoked by uid 99); 6 Jan 2011 01:12:02 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Jan 2011 01:12:02 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Jan 2011 01:11:59 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BE5C323888A6; Thu, 6 Jan 2011 01:11:38 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1055696 - /httpd/httpd/branches/2.2.x/docs/manual/mod/mod_rewrite.html.en Date: Thu, 06 Jan 2011 01:11:38 -0000 To: cvs@httpd.apache.org From: covener@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110106011138.BE5C323888A6@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: covener Date: Thu Jan 6 01:11:38 2011 New Revision: 1055696 URL: http://svn.apache.org/viewvc?rev=1055696&view=rev Log: xforms Modified: httpd/httpd/branches/2.2.x/docs/manual/mod/mod_rewrite.html.en Modified: httpd/httpd/branches/2.2.x/docs/manual/mod/mod_rewrite.html.en URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/docs/manual/mod/mod_rewrite.html.en?rev=1055696&r1=1055695&r2=1055696&view=diff ============================================================================== --- httpd/httpd/branches/2.2.x/docs/manual/mod/mod_rewrite.html.en (original) +++ httpd/httpd/branches/2.2.x/docs/manual/mod/mod_rewrite.html.en Thu Jan 6 01:11:38 2011 @@ -1102,40 +1102,84 @@ later Module:mod_rewrite

The RewriteRule directive is the real - rewriting workhorse. The directive can occur more than once, + rewriting workhorse. The directive can occur more than once, with each instance defining a single rewrite rule. The order in which these rules are defined is important - this is the order in which they will be applied at run-time.

Pattern is a perl compatible regular - expression. On the first RewriteRule it is applied to the + expression. On the first RewriteRule it is applied to the (%-encoded) URL-path of the request; subsequent patterns are applied to the output of the last matched 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. If you wish - to match against the hostname, port, or query string, use a +

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.

+ +
+ +

Per-directory Rewrites

+
    +
  • The rewrite engine may be used in .htaccess files in <Directory> sections, with some additional +complexity.
  • + +
  • To enable the rewrite engine in this context, 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 RewriteRule pattern matching +and automatically added after any relative (not starting with a +slash or protocol name) substitution encounters the end of a rule set. +See the RewriteBase +directive for more information regarding what prefix will be added back to +relative substutions.
  • + +
  • If you wish to match against the full URL-path in a per-directory +(htaccess) RewriteRule, use the %{REQUEST_URI} variable in +a RewriteCond.
  • + +
  • The removed prefix always ends with a slash, meaning the matching occurs against a string which +never has a leading slash. Therefore, A Pattern with ^/ never +matches in per-directory context.
  • + +
  • Although rewrite rules are syntactically permitted in <Location> and <Files> sections, this +should never be necessary and is unsupported.
  • +

For some hints on regular expressions, see - the mod_rewrite + the mod_rewrite Introduction.

-

In mod_rewrite, the NOT character - ('!') is also available as a possible pattern +

In mod_rewrite, the NOT character + ('!') is also available as a possible pattern prefix. This enables you to negate a pattern; to say, for instance: ``if the current URL does NOT match this pattern''. This can be used for exceptional cases, where it is easier to match the negative pattern, or as a last default rule.

+

Note

When using the NOT character to negate a pattern, you cannot include grouped wildcard parts in that pattern. This is because, when the @@ -1555,40 +1599,6 @@ flag is used on the

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> sections, this -should never be necessary and is unsupported.

- -
-

Here are all possible substitution combinations and their meanings: