I am trying to config url redirect in Apache. I have tried some approaches and nothing works. Can someone tell me the solution of this as it doesn't seem too difficult.
I am going to redirect request from:
https://myhost/configuration/jmx-console
to:
http://myanohterhost/jmx-console
This is a https to http re-direct.
Can someone point me to the right direction?
Many thanks!
You could use the RedirectMatch
directive to force Apache to send the user someplace else:
RedirectMatch 301 ^(.*)$ http://www.anotherserver.com$1
See the following:
http://httpd.apache.org/docs/2.4/mod/mod_alias.html#redirectmatch
http://en.wikipedia.org/wiki/URL_redirection#HTTP_status_codes_3xx
The normal way to do this would be the following, in the configuration of the current server (or virtual host) `myhost':
Redirect /configuration/jmx-console http://myanohterhost/jmx-console
Edit: According to your comment, it looks like you can do it using one of the following techniques:
Simply map the remote server's urls to a local url:
ProxyPass /configuration/jmx-console http://myanohterhost/jmx-console
ProxyPassReverse /configuration/jmx-console http://myanohterhost/jmx-console
RewriteRule ^configuration/jmx-console(.*)$ http://myanohterhost/jmx-console$1 [P]
There can be some caveats in using reverse proxying like this, I recommend you to read thoroughly http://httpd.apache.org/docs/2.2/en/mod/mod_proxy.html to see the various options available when using reverse proxying.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With