HOW TO: How do you redirect all https traffic to http?

There are LOTS of ways to do this.

 

This is what I do so that I can use the same code in any site’s .htaccess

RewriteEngine On
RewriteBase /
Options +FollowSymlinks
RewriteCond %{HTTPS} =on
RewriteRule ^(.*)$ http://%{SERVER_NAME}/$1 [R=301,L]

 

I like this better than checking for port 443 because sometimes load balancers handle the certificate and encryption then send the information to port 80.   This works in that situation. Of course you can adjust this code to redirect to www.%{SERVER_NAME} if that is your preference.

 

Of course redirecting all https traffic to http is equally simple by adding a ! or not to the https check and adjusting your target.

RewriteEngine On
RewriteBase /
Options +FollowSymlinks
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{SERVER_NAME}/$1 [R=301,L]

 

 

3 Comments

Add a Comment

Your email address will not be published. Required fields are marked *