'How to redirect an URL to another server using Apache
I have some trouble at work to do something I was asked to do. Our dev team developed some webservices and security policy is to use a reverse proxy between TheInternet and the webservice. I'm using a Apache server already configured for another webservice, I thought it would be easy to add another one, but I was absolutely wrong.
The thing is configured that way :
Servername is www.ourcompany.com
Location /WEBSERVICE/The/First/One
ProxyPass http://internalserver:specificport/WEBSERVICE/The/First/One
ProxyPassReverse http://internalserver:specificport/WEBSERVICE/The/First/One
Location /WEBSERVICE/The/Second/One
and then... it goes wrong. The thing is, for the first one, we used ProxyPass because except for the servername, the path is absolutely the same.
But for the second one I have some rewriting to do and I can't for the life of me figure out the correct syntax.
Basically we want the user to hit
https://www.ourcompany.com/WEBSERVICE/The/Second/One/clients/clientsIDxxxxx/something which should redirect to https://internalserver/clients/clientsIDxxxxx/something.
I tried to ProxyPass to https://internalserver, I tried
RewriteRule ^(.*)$ https://internalserver/$1
http, https, rewriterule to a specific page, only RewriteRule the clients part ( with something like ^/clients/(. *)$ ) but no success.
I have to say regex is really obscure for me, I'm pretty sure the syntax is what's causing the issue, but I do not get it. The Apache documentation did not really help me.
I have got mostly 404 error and before giving up for the day I was at the point where the redirection did something like https://internalserver/WEBSERVICE/The/Second/One/clients/clientsIDxxxxx/something, so I feel like I was close.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
