Forum Moderators: phranque

Message Too Old, No Replies

apache: redirect from one port to another

         

hugh

8:57 am on May 17, 2011 (gmt 0)

10+ Year Member



I've searched unsuccesfully and really should have a test server in a VM to practice with until then however I need help redirecting requests from one port to another such as example.com:8000 to example.com:8002. All suggestions gratefully received...

Thanks!

Hugh

g1smd

9:34 am on May 17, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Something like:

RewriteCond {HTTP_HOST} ^(www\.)?example\.com:8000$
RewriteRule (.*) http://www.example.com:8002/$1 [R=301,L]


or

RewriteCond {SERVER_PORT} ^8000$
RewriteRule (.*) http://www.example.com:8002/$1 [R=301,L]

hugh

10:47 am on May 17, 2011 (gmt 0)

10+ Year Member



Neither is working unfortunately. Any suggestions?

hugh

10:58 am on May 17, 2011 (gmt 0)

10+ Year Member



iptables was my answer:

iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
iptables-save

Thanks for the feedback g1smd!

g1smd

11:32 am on May 17, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



There was a typo in my code, the { should have been %{ here.