Apache RewriteRule Proxy has bad headers

apache-2.2PROXY

Im trying to create a proxy from a location on our site to a thrird party's site. Eg

http://www.mysite.com/cat -> proxys to http://www.cat.com

This is the line from my config:

 RewriteRule ^cat/?$ http://cat.com:80 [P]

The proxy essentially works, but the problem is that it returns an error 400 Bad Request. Looking at the Apache access log of the site im proxying to, the incoming request is:

[18/Oct/2011:13:04:46 +0100] "GET  HTTP/1.1" 400 334 "-" "-"

There is no referrer, host, anything. The server returns to the browser:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
<hr>
<address>Apache/2.2.12 (Ubuntu) Server at {cut} Port 80</address>
</body></html>

Any ideas- any help would be great!

Thanks

Best Answer

 RewriteRule ^cat($|/.*) http://cat.com$1 [P,L]

But this could fail.

The best way in our organization is to map the same path in both:

www.upc.edu/grau -> sites.upc.edu/grau

and not:

www.upc.edu/grau -> sites.upc.edu/

or

www.upc.edu/grau -> sites.upc.edu/~grau

You can create an alias in destination if needed:

Alias /grau /var/www/docs/grau/  (p.e.)
Related Topic