Sometimes, even after installing an SSL Certificate on your domain, it does not automatically redirect you to the https version of your website. In that case, we need to force SSL. Let’s see how we can do it using some simple code in our website’s .htaccess file.
Here is the Force SSL / ALWAYS ON HTTPS code for any Apache server-based website:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Just copy those 3 lines carefully and paste them to the very top of your .htaccess file. If you don’t see an .htaccess file, you either need to turn on show hidden files or manually create it. And then simply save it. Done! Now visit your website to ensure it’s working.
