When using Apache 2.0.49 mod_rewrite with rewrite-maps on proxied requests, apache applies a false per-dir prefix and garbles the url. Apache 2.0.48 was working as expected. I have the following statements in my httpd.conf (simplified): RewriteMap proxy-map prg:/usr/local/bin/proxy-map RewriteMap local-map prg:/usr/local/bin/proxy-local-map <Proxy *> RewriteEngine On RewriteCond %{SERVER_ADDR} ^127\.0\.0 RewriteRule ^proxy:http://id/$ http://localhost/cgi-bin/id [R,L] RewriteRule ^(.*)$ ${proxy-map:$1|$1} RewriteCond %{SERVER_ADDR} ^127\.0\.0 RewriteRule ^(.*)$ ${local-map:$1|$1} </Proxy> The output of RewriteLog on Level 9: (3) [per-dir */] applying pattern '^proxy:http://id/$' to uri 'proxy:http://www.apache.org/' (3) [per-dir */] applying pattern '^(.*)$' to uri 'proxy:http://www.apache.org/' (5) map lookup OK: map=proxy-map key=proxy:http://www.apache.org/ -> val=proxy:http://www.apache.org/ (2) [per-dir */] rewrite proxy:http://www.apache.org/ -> proxy:http://www.apache.org/ (3) [per-dir */] add per-dir prefix: proxy:http://www.apache.org/ -> */proxy:http://www.apache.org/ (3) [per-dir */] strip per-dir prefix: */proxy:http://www.apache.org/ -> proxy:http://www.apache.org/ (3) [per-dir */] applying pattern '^(.*)$' to uri 'proxy:http://www.apache.org/' (4) RewriteCond: input='127.0.0.1' pattern='^127\.0\.0' => matched (5) map lookup OK: map=local-map key=proxy:http://www.apache.org/ -> val=proxy:http://www.apache.org/ (2) [per-dir */] rewrite proxy:http://www.apache.org/ -> proxy:http://www.apache.org/ (3) [per-dir */] add per-dir prefix: proxy:http://www.apache.org/ -> */proxy:http://www.apache.org/ Nothing in the error-log, and only the following in the access-log: 127.0.0.1 - - [26/Mar/2004:15:02:58 +0100] "GET http://www.apache.org/ HTTP/1.1" 400 - "-" "Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.6) Gecko/20040312" 0 "-"
Hrm. That is a problem. mod_rewrite now treats the result string 'proxy:http://www.apache.org/' as a relative path, which was a bug fix in 2.0.49 (for some other example, but ...). Frankly speaking, your rules depend on unsupported API internals, so you cannot expect that they work forever. Anyway: Can you try what happens if you just take the rules out of the <Proxy> container? (That's even the next problem, mod_rewrite was never designed for use within <Proxy>).
> Frankly speaking, your rules depend on unsupported API internals I didn't even know that this setup was unsupported ;) It worked with only minor changes (<Location proxy:*> changed to <Proxy *>) from a very old apache 1.3 through 2.0.48 without problems. I will try your suggestion on monday, when I can reach my test-box again.
I just tried your suggestion of placing the RewriteRules outside of <Proxy>: The Rules are tested only for local connections, not for connections proxied through the apache. Thus they are called exactly when I don't need any rewriting. I'm back to apache 2.0.48 for now.
Well, thanks. I'm investigating how to fix it somehow.
I've nailed the problem in 2.1 and proposed it for backport into the 2.0 branch. If you want to to try it out, here's a patch against 2.0: <http://cvs.apache.org/~nd/mod_rewrite.c.patch>
Just a small follow-up: Your patch fixes my problems with 2.0.49, the rewrite/filter rules are working again. Thanks a lot.
Thanks for the feedback :-)
This bug is in 2.0.50 too, and the same patch as for 2.0.49 still fixes it.
Well, the fix was finally reviewed and will be in 2.0.51.