Oracle B12255-01 Benutzerhandbuch

Seite von 224
mod_rewrite
7-54
Oracle HTTP Server Administrator’s Guide
mod_rewrite
 loops through the ruleset rule by rule (RewriteRule directive) and
when a particular rule matches, it loops through corresponding conditions
(RewriteCond directives). First the URL is matched against the Pattern of each
rule. When it fails, mod_rewrite looks for corresponding rule conditions. If none
are present, it just substitutes the URL with a new value which is constructed from
the string Substitution and goes on with its rule-looping. But if conditions exist,
it starts an inner loop for processing them in the order that they are listed.
For conditions, a string TestString is created by expanding variables,
back-references map lookups, and then CondPattern is matched against the
expanded TestString. If the pattern does not match, the complete set of
conditions and the corresponding rule fails. If the pattern matches, then the next
condition is processed until no more conditions are available. If all conditions
match, processing is continued with substituting the URL using Substitution.
When request seeks a URL with more than one slash (/), for example,
http://yourserver//oldpath/rqstdrsrc
, the “//oldpath” may bypass
RewriteCond
 and RewriteRule directives if they are not correctly written.
For example, consider the following rule:
RewriteRule ^/oldpath(.*) /newpath$1 [R]
Requesting http://yourserver/oldpath/files will redirect and return the
page http://yourserver/newpath/files as expected.
However, requesting http://yourserver//oldpath/files will bypass this
particular rule, potentially serving a page that you were not expecting it to. You can
work around the problem by making sure that rules will capture more than one
slash (/). To fix the earlier example, you should use this replacement:
RewriteRule ^/+somepath(.*) /otherpath$1 [R]