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'