Bug 63262 - RewriteRule in <If> section matches against file system path instead of URI path
Summary: RewriteRule in <If> section matches against file system path instead of URI path
Status: NEW
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_rewrite (show other bugs)
Version: 2.4.38
Hardware: All All
: P2 normal with 3 votes (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-15 10:09 UTC by Klaus Johannes Rusch
Modified: 2019-03-15 10:09 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Klaus Johannes Rusch 2019-03-15 10:09:21 UTC
When using RewriteRule in <If> context, the pattern is matched against the file system path instead of the URI path:

httpd.conf:

<IfModule rewrite_module>
RewriteEngine on
LogLevel alert rewrite:trace8

<If "true">
  RewriteRule ^(.*)$ http://example.localhost/?$1 [R=302,L]
</If>
</IfModule>

Request: http://example.com/test
Expected response: Redirect to http://example.localhost/?/test
Received response: Redirect to http://example.localhost/?/usr/www/htdocs/test

Rewrite log:
[Fri Mar 15 10:52:15.994467 2019] [mpm_winnt:notice] [pid 4976:tid 408] AH00455: Apache/2.4.38 (Win64) OpenSSL/1.0.2r configured -- resuming normal operations
[Fri Mar 15 10:52:26.369060 2019] [rewrite:trace2] [pid 10744:tid 1128] mod_rewrite.c(483): [client 127.0.0.1:62192] 127.0.0.1 - - [localhost/sid#1d7798][rid#290ff40/initial] init rewrite engine with requested uri /test
[Fri Mar 15 10:52:26.369060 2019] [rewrite:trace1] [pid 10744:tid 1128] mod_rewrite.c(483): [client 127.0.0.1:62192] 127.0.0.1 - - [localhost/sid#1d7798][rid#290ff40/initial] pass through /test
[Fri Mar 15 10:52:26.377060 2019] [rewrite:trace3] [pid 10744:tid 1128] mod_rewrite.c(483): [client 127.0.0.1:62192] 127.0.0.1 - - [localhost/sid#1d7798][rid#290ff40/initial] [perdir *If/] applying pattern '^(.*)$' to uri '/usr/www/htdocs/test'
[Fri Mar 15 10:52:26.377060 2019] [rewrite:trace2] [pid 10744:tid 1128] mod_rewrite.c(483): [client 127.0.0.1:62192] 127.0.0.1 - - [localhost/sid#1d7798][rid#290ff40/initial] [perdir *If/] rewrite '/usr/www/htdocs/test' -> 'http://example.localhost/?/usr/www/htdocs/test'