Force HTTPS Redirect from HTTP for SSL

//Force HTTPS Redirect from HTTP for SSL

Force HTTPS Redirect from HTTP for SSL

With the web transforming nearly every day, and the need for privacy and security growing higher and higher, there is a huge demand on web developers now a days, to provide even if the site is purely informational; A SSL certificate for some level of encryption on the input/output of the data from their sites, services, other. With that demand comes the need to drive your traffic to the right place to ensure that security they are looking for.

Now while the code under the hood remains fairly the same, your server isn’t likely going to by default at least redirect your traffic from http://domain.com to https://domain.com.

One way to enforce the use of protocols is to add a couple quick lines to the top of your .htaccess file (depending how you have it setup at least). 

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]

This is basically checking to see if the requested protocol from the browser is HTTP if it is (ie: off) then redirect your request premaritally via 301 header being used while redirecting from http to https the request you made.

If you are using wordpress you could also install these two plugins to make it even easier. The first one involves the actual redirection from protocol to protocol while the other will help you obtain and automatically re-obtain on expiration a SSL certificate for free The first plugin is Easy HTTPS (SSL) Redirection the next is WP-Encrypt provided by the free cert authority Let’s Encrypt though I do not advice using Let’s Encrypt if you are doing e-Commerence or other similar service where extremely sensitive data is passing hands.

By | 2017-08-03T23:25:49+00:00 July 15th, 2017|Random|0 Comments

About the Author:

Not much to know about me, I'm a 35+ year old coder, geek, gamer..

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: