How to Redirect HTTP to HTTPS automatically

Sunday, 12 November 2017

If you have a secure certificate (SSL) on your website, you can automatically redirect visitors to the secured (HTTPS) version of your website to make sure their information is protected.

How you redirect traffic depends on the type of hosting and CMS you have.

If you use wordpress, you need to set both Site URL and Home URLs options of your wordpress to use https://.
That will force Wordpress to use https for your website.

CPanel 80 and up
Login to your CPanel account
Go to Domains
Locate your domain and Turn on the Switch button under 'Force HTTPS Redirect' column.
Your domain should redirect to https automatically.

If it doesn't work, continue to the steps below to do it manually.

.htaccess file

Cpanel accounts use .htaccess files to handle redirection.

You can find your .htaccess file in you Control Panel>>File Manager>>Public_html

If your .htaccess file is hidden, you may need to show all hidden files.

To show hidden files in File Manager, click on the "Settings" button with the gear-like icon on your top-right corner of the page and then check the "Show Hidden Files (dotfiles) " option. You may disable this after you finish modifying the file.

Note: If you need to create a .htaccess file, you can go to your Control Panel >> File Manager >> "+ File"/"Create File" button at the top most part of the page.

Next, click on the .htaccess file and then click on "Edit" on the top part of the File Manager Page to edit it.

Using the following code in your .htaccess file automatically redirects visitors to the HTTPS version of your site:

RewriteEngine On
RewriteCond %{HTTPS} !=on 
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

If you have an existing .htaccess file:

Do not duplicate RewriteEngine On.

Make sure the lines beginning RewriteCond and RewriteRule immediately follow the already-existing RewriteEngine On.

Back to list