samjhana joshi
samjhana joshi

Reputation: 2015

how to redirect certain url to port using .htaccess

I am trying to redirect url as abc.xyz.org to 192.168.xx.yy:abcd using htaccess. tried using following in htaccess.

RewriteRule ^(.*)$ 192.168.xx.yy:abcd [P,R=301,L]

but this rule isn't taking the port number.What should I do? i tried

RewriteRule ^(.*)$ 192.168.xx.yy:abcd[b] [P,R=301,L]

Upvotes: 4

Views: 2529

Answers (3)

Satish Rajput
Satish Rajput

Reputation: 49

RewriteEngine On

RewriteRule ^(.*)$ index.php$1 [R=301, L]

Upvotes: 0

chanchal118
chanchal118

Reputation: 3657

RewriteRule ^(.*)$ http://192.168.xx.yy:abcd [P,R=301,L]

Your using [P] flag. Make sure mod_proxy is enabled. In this doc it says Note: mod_proxy must be enabled in order to use this flag. To enable mod_proxy give command

sudo a2enmod proxy

Then restart apache

If you can not enable mod_proxy [P] flag is of no use. Then your rewrite rule will be

RewriteRule ^(.*)$ http://192.168.xx.yy:abcd [R=301,L]

Upvotes: 0

W Kristianto
W Kristianto

Reputation: 9313

Try this

RewriteEngine on
RewriteRule ^(.*)$ http://192.168.0.1:1234/$1 [R=301,L]

Upvotes: 1

Related Questions