X-Git-Url: https://granicus.if.org/sourcecode?a=blobdiff_plain;f=docs%2Fmanual%2Fmod%2Fmod_rewrite.html.en;h=2d2c62122b3133ba807413c286fa393a702c706a;hb=31c8cd4655929a1a4a8c12f1b6e3489bc06ac54e;hp=e71ee5d1258890d25633c1e0655f4bff2679fcab;hpb=cee998d39bf65f3edc8c811e87aacb2c638047a0;p=apache diff --git a/docs/manual/mod/mod_rewrite.html.en b/docs/manual/mod/mod_rewrite.html.en index e71ee5d125..2d2c62122b 100644 --- a/docs/manual/mod/mod_rewrite.html.en +++ b/docs/manual/mod/mod_rewrite.html.en @@ -68,7 +68,9 @@ URLs on the fly
RewriteRule
directives that
substitute a relative path.
This directive is required when you use a relative path - in a substitution in per-directory (htaccess) context unless either + in a substitution in per-directory (htaccess) context unless any of the following conditions are true:
Alias
or mod_userdir
. RewriteCond
- TestString CondPattern
If the TestString has the special value expr
, the
CondPattern will be treated as an
ap_expr.
RewriteCond expr "! %{HTTP_REFERER} -strmatch '*://%{HTTP_HOST}/*'"
+RewriteCond expr "! %{HTTP_REFERER} -strmatch '*://%{HTTP_HOST}/*'" RewriteRule "^/images" "-" [F]
You can also set special flags for CondPattern by appending
[
flags]
as the third argument to the RewriteCond
directive, where flags is a comma-separated list of any of the
- following flags:
-
+ following flags:
nocase|NC
'
(no case)Example:
@@ -1016,7 +1016,25 @@ RewriteRule "^/$" "/homepage.std.html" [L] extended URL and filesystem context information to change the relative substitution back into a URL. Modules such asmod_userdir
and mod_alias
- supply this extended context info.
+ supply this extended context info. Available in 2.4.16 and later.
+
+
+
+ LegacyPrefixDocRoot
Prior to 2.4.26, if a substitution was an absolute URL that matched
+ the current virtual host, the URL might first be reduced to a URL-path
+ and then later reduced to a local path. Since the URL can be reduced
+ to a local path, the path should be prefixed with the document root.
+ This prevents a file such as /tmp/myfile from being accessed when a
+ request is made to http://host/file/myfile with the following
+ RewriteRule
.
RewriteRule /file/(.*) http://localhost/tmp/$1+ +
This option allows the old behavior to be used where the document + root is not prefixed to a local path that was reduced from a + URL. Available in 2.4.26 and later.
Pattern is a perl compatible regular - expression. On the first RewriteRule, it is matched against - the (%-decoded) URL-path - of the request, or, in per-directory context (see below), the URL - path relative to that per-directory context. Subsequent patterns - are matched against the output of the last matching RewriteRule.
+ expression. What this pattern is compared against varies depending + on where theRewriteRule
directive is defined.
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 led the server
- to the current RewriteRule
(e.g. "app1/index.html"
- or "index.html" depending on where the directives are defined).
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").
+ This is the (%-decoded) URL-path.
In per-directory context (Directory
and .htaccess),
+ the Pattern is matched against only a partial path, for example a request
+ of "/app1/index.html" may result in comparison against "app1/index.html"
+ or "index.html" depending on where the RewriteRule
is
+ defined.
The directory path where the rule is defined is stripped from the currently mapped + filesystem path before comparison (up to and including a trailing slash). + The net result of this per-directory prefix stripping is that rules in + this context only match against the portion of the currently mapped filesystem path + "below" where the rule is defined.
+ +Directives such as DocumentRoot
and Alias
, or even the
+ result of previous RewriteRule
substitutions, determine
+ the currently mapped filesystem path.
+
If you wish to match against the hostname, port, or query string, use a +
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.
In any case, remember that regular expressions are substring
- matches. That is, you don't need the regex to describe the entire
- string, just the part that you wish to match. Thus, using a regex
- of .
is often sufficient rather than .*
,
- and the regex abc
is not the same as
- ^abc$
.
%{QUERY_STRING}
variables respectively.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 RewriteBase
+RewriteBase
directive for more information regarding what prefix will be added back to
relative substitutions.$N
in the substitution string!