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]
Summary of Contents for HTTP Server
Page 1: ...Oracle HTTP Server Administrator s Guide 10g Release 1 10 1 Part No B12255 01 December 2003 ...
Page 12: ...xii ...
Page 22: ...xxii ...
Page 38: ...About htaccess Files 2 8 Oracle HTTP Server Administrator s Guide ...
Page 52: ...Getting Information about Processes 4 8 Oracle HTTP Server Administrator s Guide ...
Page 60: ...Configuring Reverse Proxies and Load Balancers 5 8 Oracle HTTP Server Administrator s Guide ...
Page 70: ...Specifying Log Files 6 10 Oracle HTTP Server Administrator s Guide ...
Page 170: ...9 6 Oracle HTTP Server Administrator s Guide ...
Page 178: ...opmn xml A 8 Oracle HTTP Server Administrator s Guide ...
Page 212: ...Glossary 10 ...
Page 224: ...Index 12 ...