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 you have.

Linux & cPanel

Linux-based accounts use .htaccess files to handle redirection.

You can find you .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