To force all web traffic to use the HTTPS version of your URL, enter the following lines of code in the .htaccess file in your root folder.

  1. Open your website’s .htaccess file in cPanel File Manager or via FTP
  2. Copy and paste the code below into your .htaccess file
  3. Save

.htaccess code to force https://

    # ----------------------------------------------------------------------
    # | Forcing `https://`                                                 |
    # ----------------------------------------------------------------------
    # Redirect from the `http://` to the `https://` version of the URL.
    <ifmodule mod_rewrite.c>
      RewriteEngine On
      RewriteCond %{HTTPS} !=on
      RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

Source:html5-boilerplate .htaccess