how do I redirect a page within a website

CharanR
CharanR used Ask the Experts™
on
I want to redirect

http://192.168.15.6:20001/voice/framework.jsp
to https://192.168.15.6:20012/voice/framework.jsp

does this work in httpd.conf

Redirect permanent http://(.*):20001/voice/framework.jsp https://$1:20012/voice/framework.jsp

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2010
Commented:
Hi

Not quite, you'll want something like the following, in your 20001 VirtualHost definition:

Redirect permanent /voice/framework.jsp https://192.168.15.16:20012/voice/framework.jsp

Alternatively:

RewriteEngine On
RewriteRule ^/voice/framework.jsp   https://192.168.15.16:20012%{REQUEST_URI} [R=301,L]

Yo may also want to add a rule to the 20012 VirtualHost definition, to direct requires that should be in http (not https) back to the  20001 host. Plenty of examples around.

Author

Commented:
how can I do this for any IP
the condition you gave me worked for me
Top Expert 2010

Commented:
If it's an IP, rather than host name, then something like the following should work (un-tested):

RewriteEngine On
RewriteCond %{HTTP_HOST}   ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+):
RewriteRule ^/voice/framework.jsp   https://%1:20012%{REQUEST_URI} [R=301,L]

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial