From: Eric Covener The 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. 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 In If you wish to match against the hostname, port, or query string, use a
For some hints on In mod_rewrite, the NOT character
- (' In mod_rewrite, the NOT character
+ ('%{HTTP_HOST}
, %{SERVER_PORT}
, or
%{QUERY_STRING}
variables respectively.
+
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..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 %{REQUEST_URI}
variable in
+a ^/
never
+matches in per-directory context.!
') is also available as a possible pattern
+ !
') 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.
This expansion does not occur when the PT
flag is used on the
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
-
The rewrite engine may also be used in .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
Although rewrite rules are syntactically permitted in
Here are all possible substitution combinations and their