Let's say I have the following subdomain with its own document root etc:
monad2.mysite.com
I want that all requests are proxied to an IP (for instance 193.159.3.129
) but they must pass through the server at mysite.com
(assuming monad2
is on this same server).
I have the following (htaccess) config which works up to the subdomain, but fails to proxy any other request...
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://193.159.3.129/$1 [P]
My problem is that while it does work for http://monad2.mysite.com/a.php
(url remains the same), it doesn't work with requests like http://monad2.mysite.com/a/b
(url is converted to http://193.159.3.129/a/b
). Note that the latter address shows a directory listing of the proxied server, which is correct, except that the subdomain changed to an ip.
Also, I presume this system will definitely not work for HTTPS requests, correct?
Edit: After some more troubleshooting, I've found exactly when the problem is being caused. Whenever I try to access a directory without the final slash, the proxy fails, and I end up with an IP. Some example:
Original | Result
--------------------------------+--------------------------------
http://monad2.mysite.com | http://monad2.mysite.com
http://monad2.mysite.com/a/ | http://monad2.mysite.com/a/
http://monad2.mysite.com/a | http://193.159.3.129/a/ <- !
http://monad2.mysite.com/a.php | http://monad2.mysite.com/a.php