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.
- Open your website’s .htaccess file in cPanel File Manager or via FTP.
- Copy and paste the code below into your .htaccess file
- Save
.htaccess code to force https://
# ----------------------------------------------------------------------
# | Forcing `https://` |
# ----------------------------------------------------------------------
# Redirect from the `http://` to the `https://` version of the URL.
# https://wiki.apache.org/httpd/RewriteHTTPToHTTPS
<ifmodule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
</ifmodule>
