I am trying to combine a rewrite and a proxy pass and having issues with the rewrite. Here is what I have
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.world.net
RewriteRule %{HTTP_HOST} http://newexample.newworld.net:7802/apex/f?p=208 [R,P]
ProxyPass / http://newexample.newworld.net:7802/
The proxypass is working, but I can't figure out how to get the initial redirect. So if the user puts in example.world.net/apex/f?p=208 it goes to newexample.newworld.net:7802/apex/f?p=208 and masks the url.
However I need to get example.world.net to redirect to example.world.net/apex/f?p=208 if the apex/f?p=208 is not in the url.
You can't redirect and proxy at the same time. Your rewrite rule flags are
[R,P]
which is "redirect" and "proxy". You'll need one or the other here. Also, your rule's regex is never going to match%{HTTP_HOST}
, unless your URL is literally:http://example.world.net/%{HTTP_HOST}
. You'll need to change it to:This will redirect the browser if the URL address bar says
http://example.world.net/
tohttp://example.world.net/apex/f?p=208
. Then, it's up to the proxy to take/apex/f?p=208
and proxy it tohttp://newexample.newworld.net:7802/
.There's a possibility that mod_proxy and mod_rewrite won't play nicely together because both can end up getting applied to the same URL. If you find that both are getting applied at the same time, then change the
ProxyPass
line to:So you want example.world.net to redirect to http://newexample.newworld.net:7802/apex/f?p=208 or to example.world.net/apex/f?p=208 ? I assume the former, if I'm wrong change url in RewriteRule to the latter.
but I think this should do it
but then it is unknown what is the Name/Aliases of your virtual host, so that / in
might break it all.