In the initial stage of learning web development, we think that hosting a website, and getting HTTP in the URL could be the last stage of development. To an extent it is, but after hosting a website more responsibility falls down on the shoulder of the developer. That responsibility is to maintain the security and integrity of the website.
Why do we need to redirect it to HTTPS?
In order to understand why do we need to redirect our website to HTTPS we first need to know what HTTPS is? so HTTP stands for hypertext transfer protocol whereas HTTPS stands for hypertext transfer protocol secure. HTTPS is an extension of HTTP which is a protocol followed by the internet in order to maintain secure communication over the internet.
Find out detailed version about HTTP and HTTPS on Moving from HTTP to HTTPS
In the late 90s network engineers found that there is a glitch in HTTP which sometimes hurt the security of the website. or we can say that hackers found it easy to intrude on the communication that happened in HTTP website. so this problem urges the network engineers to work on it and they successfully made an extension of HTTP, namely HTTPS which works under the certificate of the secure socket layer(SSL). Basically what HTTPS does is provides end-to-end encryption between the user and the website which results in ensuring the integrity and security of the website.
Steps to force HTTP redirects to HTTPS in cPanel
This is necessary to serve your website through one protocol either its HTTP or HTTPS. Because google takes both protocols differently so to avoid any backlink loss or google identification problem. You should use one protocol and the preferred one is HTTPS if available. To help you force HTTP to HTTPs from your cPanel we have produced a video as well.
Primary Domains
The prerequisite to force HTTP to redirect to HTTPS in cpanel is to install the secure socket layer(SSL) certificate. Once you are done with it you will see a small lock appears under the primary domain of your website.
now what you have to do is to scroll down the page till you find the domain section. Here you will see a primary domain, click on it.
now you will redirect to the next page where you will find different columns. Go to the column named force HTTPS redirect and turn it on.

now your website is successfully redirected to HTTPS as shown in this green dialogue box.
Add-on Domains
In the Add-on domains there is not an option to turn on the redirection to HTTPS so in that case, what we do is

Go to the root of the domain
you will see a list of files. Edit the .htaccess file with these 3 lines of code
/*
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
*/
Remove the steric and slash from both ends. It is just to separate the code from the instruction.
Make sure you don’t have this line already in the .htaccess file /* RewriteEngine On */
To understand completely how to redirect http: to https:// through .htaccess file checkout How To Redirect HTTP To HTTPS In Apache
If you have this line already present in the file skip this line just copy-paste the other two lines in the file.
save changes and now this add-on domain will always be redirected to HTTPS no matter from where you open it.
If you find this helpful go to our website for more such articles Webful Creations.
2 Comment(s)