How to force https using htaccess easily


Nowdays people are very cautious about their security online. So having an SSL certificate is must for website. But only having SSL will not solve your security issues. It is also very important that all your domains redirect to secure version of your website . In simple words it’s like loading domain with https for example

Htaccess Code to add SSL code in .htaccess file. You need to edit this file in root of your website. Or if it’s not there create a new file with name .htacess

RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Above code will force HTTPS on your website. And will redirect users to https version of website.

Tip for WordPress Website

If you are using WordPress you can simple install this plugin Really SImple SSL . It simply require installing and activating it. It is super simple and manages all very easily.

Get Free SSL with cloudflare

For small businesses buying SSL can be a bit expensive. But you can use cloudflare to add free SSL and caching to your site. Here is the link you can follow for guide.

Let me know your views and if you face any problem with code let me know in comments.