Forum Moderators: phranque

Message Too Old, No Replies

question: rewrite rule

         

caesarkim

5:41 pm on May 1, 2006 (gmt 0)

10+ Year Member



I have two apache web servers running in a single machine. One listens to port 80 and the other one listens to port 81. 81 is behind the firewall. So i want to forward all the requests to port 81 coming through port 80. but for the following lines that I tried with, it shows port number 81 at the address bar. I want to hide it. is there any way to hide port number?

Thanks.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteLog "logs/rewrite_log"
RewriteLogLevel 0
RewriteRule "(.*)" "http://www.test.com:81$1"
</IfModule>

jdMorgan

10:32 pm on May 1, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try using the [P] flag to make your rule do a proxy throughput to the back-end server, rather than doing the (default) 302 redirect:

RewriteRule (.*) http://www.example.com:81$1 [P]

Jim

c0liding l0gic

7:14 am on May 21, 2006 (gmt 0)

10+ Year Member



I'm having the same problem, can anyone help, the rule RewriteRule (.*) http://www.example.com:81$1 [P] still shows port 81 in the browser address bar?!?

c0liding l0gic

3:20 pm on May 21, 2006 (gmt 0)

10+ Year Member



Here is the solution for those of you out there, mod_proxy, mod_proxy_http and mod_vhost_alias are required:

<VirtualHost *:80>
ServerName www.yourdomain.com
ServerAlias yourdomain.com www.yourdomain.com
ErrorLog logs/www.yourdomain.com-error_log
CustomLog logs/www.yourdomain.com-access_log common
ProxyRequests Off

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

ProxyPass / [yourdomain.com:81...]
ProxyPassReverse / [yourdomain.com:81...]
</VirtualHost>