Posts Tagged ‘80 to anyport redirect’

.htaccess – redirect from http to https

February 23rd, 2010

The simplest code i have found so far to redirect from http to https is:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Just place this in your .htaccess file and it should work.  The same principal can be used to redirect users from https to http with

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}

Finally to redirect a user from 1 port (any port) to another you could use:

RewriteEngine On
RewriteCond %{SERVER_PORT} 443
RewriteRule (.*) [R]

This will redirect from 443 to “newport”.

if you found this helpful feel free to donate to:
ZEC: t1NQp1UuqQbmnXzazbLTSreS2AbaZpRBuTM
LTC: LZyNF1qkBUA7XFz83m5xwzGgmmj1owQn9d