.htaccess - Apache redirect to a port and mask the URL -


i have 1 web server running 2 sites on different ports. ie: server:8081 , server:8083 setup 2 dns records , pointed “my server”

dev.server.com , pre.server.com

i dev.server.com redirect server:8083 mask url stay dev.server.com , pre.server.com redirect server:8081 mask url stay pre.server.com

if set them this

<virtualhost *:80> servername http:// dev.server.com proxyrequests off proxypass / http://server:8083 proxypassreverse / http://server:8083 </virtualhost>  <virtualhost *:80> servername http:// pre.server.com proxyrequests off proxypass / http://server:8081 proxypassreverse / http://server:8081 </virtualhost> 

everything routes dev instance , nothing makes pre instance

i have set this;

<virtualhost *:80> servername http:// dev.server.com rewriteengine on rewritecond %{http_host} ^dev\.server\.com$ [nc] rewriterule ^(.*)$ http:// dev.server.com:8083$1 [r] rewritecond %{http_host} ^pre\.server\.com$ [nc] rewriterule ^(.*)$ http://pre. server.com:8081$1 [r] </virtualhost> listen 0.0.0.0:8083 listen 0.0.0.0:8081 <virtualhost *:8083> servername dev. server.com proxyrequests off proxypass / http:// server.com:8083/jde/owhtml/ proxypassreverse / http:// server.com:8083/jde/owhtml/ oc4jmount /jde html_dv_8083 oc4jmount /jde/* html_dv_8083 </virtualhost>  <virtualhost *:8081> servername pre.server.com proxyrequests off proxypass / http:// server.com:8081/jde/owhtml/ proxypassreverse / http:// server.com:8081/jde/owhtml/ oc4jmount /jde html_py_8081 oc4jmount /jde/* html_py_8081 </virtualhost> 

this works routing not mask url. adds port url witch not want happen.

anyone have ideas doing wrong?

you want reverse proxy happen in port 80 vhost. because you're using mod_rewrite to redirect browser to urls http://dev.server.com:8083/, that's browser see. need 2 vhosts on port 80:

<virtualhost *:80>   servername dev.server.com    proxyrequests off   proxypass / http://server.com:8083/jde/owhtml/   proxypassreverse / http://server.com:8083/jde/owhtml/   oc4jmount /jde html_dv_8083   oc4jmount /jde/* html_dv_8083 </virtualhost>  <virtualhost *:80>   servername pre.server.com    proxyrequests off   proxypass / http://server.com:8081/jde/owhtml/   proxypassreverse / http://server.com:8081/jde/owhtml/   oc4jmount /jde html_py_8081   oc4jmount /jde/* html_py_8081 </virtualhost> 

note "servername" dev.server.com , pre.server.com, , not http:// dev.server.com space following scheme , ://. because http:// dev.server.com isn't going hostname you're going visit, apache defaults first vhost. why second attempt works, because both dev , pre default first vhost since nothing matches on port 80.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -