HTTP to HTTPS Redirect via HTAccess

, , , ,

So to have an entire site get redirected from HTTP to HTTPS you can use the following redirect code within the .htaccess file.

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$$1 [R,L]

and to go in reverese

RewriteEngine On 
RewriteCond %{SERVER_PORT} 443 
RewriteRule ^(.*)$$1 [R,L]

Doing it these ways allows you to stop the attempted loading of a bad SSL certificate before it happens.


Posted on

April 14, 2017

Submit a Comment

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