If you do not have a .htaccess file, create a .htaccess file in the public_html folder or in the root folder of the site.
1. Write the following code to the file:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
2. If the .htaccess file already exists
Don't duplicate RewriteEngine On.
Ensure that lines starting with RewriteCond and RewriteRule immediately follow RewriteEngine On.