In the mod_rewrite examples page the following can be found:

RewriteEngine on
RewriteCond %{REQUEST_URI} !-U
RewriteRule ^(.*) http://webserverB.dom/$1

[Not related comment: shouldn't this be ^/(.*)]

A request for http://localhost/foo/bar results in the following log:

127.0.0.1 - - [16/Oct/2005:17:34:06 +0200] [windows.joost.localnet/sid#46a8b0][rid#4b1900/initial] (2) init rewrite engine with requested uri /foo/bar 127.0.0.1 - - [16/Oct/2005:17:34:06 +0200] [windows.joost.localnet/sid#46a8b0][rid#4b1900/initial] (3) applying pattern '^(.+)' to uri '/foo/bar' 127.0.0.1 - - [16/Oct/2005:17:34:06 +0200] [windows.joost.localnet/sid#46a8b0][rid#4c7a48/subreq] (2) init rewrite engine with requested uri /foo/bar 127.0.0.1 - - [16/Oct/2005:17:34:06 +0200] [windows.joost.localnet/sid#46a8b0][rid#4c7a48/subreq] (3) applying pattern '^(.+)' to uri '/foo/bar' 127.0.0.1 - - [16/Oct/2005:17:34:06 +0200] [windows.joost.localnet/sid#46a8b0][rid#4c7a48/subreq] (4) RewriteCond: input='/foo/bar' pattern='!-U' => matched 127.0.0.1 - - [16/Oct/2005:17:34:06 +0200] [windows.joost.localnet/sid#46a8b0][rid#4c7a48/subreq] (2) rewrite /foo/bar -> http://webserverB.dom//foo/bar 127.0.0.1 - - [16/Oct/2005:17:34:06 +0200] [windows.joost.localnet/sid#46a8b0][rid#4c7a48/subreq] (2) implicitly forcing redirect (rc=302) with http://webserverB.dom//foo/bar 127.0.0.1 - - [16/Oct/2005:17:34:06 +0200] [windows.joost.localnet/sid#46a8b0][rid#4c7a48/subreq] (1) escaping http://webserverB.dom//foo/bar for redirect 127.0.0.1 - - [16/Oct/2005:17:34:06 +0200] [windows.joost.localnet/sid#46a8b0][rid#4c7a48/subreq] (1) redirect to http://webserverB.dom//foo/bar [REDIRECT/302] 127.0.0.1 - - [16/Oct/2005:17:34:06 +0200] [windows.joost.localnet/sid#46a8b0][rid#4b1900/initial] (5) RewriteCond URI (-U) check: path=/foo/bar -> status=302 127.0.0.1 - - [16/Oct/2005:17:34:06 +0200] [windows.joost.localnet/sid#46a8b0][rid#4b1900/initial] (4) RewriteCond: input='/foo/bar' pattern='!-U' => not-matched 127.0.0.1 - - [16/Oct/2005:17:34:06 +0200] [windows.joost.localnet/sid#46a8b0][rid#4b1900/initial] (1) pass through /foo/bar

So instead of getting redirected, the -U seems to get applied again, sees the request resulted in a 302 redirect, and decides that it's a valid URL after all, so it's passed through, leading to a 404 error, instead of the redirect.

Am I misinterpreting the results, is the example wrong, or is something weird going on in mod_rewrite with -U?

Joost

Reply via email to