force ssl htaccess

Sometimes your website cannot redirected to SSL connection after installing SSL Certificates. In this case, you can forcefully redirect your website non SSL to SSL. To do so, you have to edit .htaccess file.

Force SSL htaccess

Step-1: Login to cPanel > Filemanager.

Step-2: Go to your website directory. (for your main service domain, public_html is default website directory)

Step-3: Locate .htaccess file and right click on it and select edit.

Step-4: Paste the below code and save!

#FORCED SSL START
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#FORCED SSL END
Now clear your browser cache memory and reload the website again. You’ll see, it is loading with https.
If the above code doesn’t works properly, you can try the below code instead:
#FORCED SSL START
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]
</IfModule>
#FORCED SSL END
NOTE: .htaccess file is hidden in your cpanel filemanager. To see the file click the gear icon at the to right corner and check show hidden files. If still don’t find .htaccess file, create a new file from the top bar option and name it .htaccess

Like This Article? Get Cloud Hosting Today