Two ways to force SSL on your website

Two solutions, both to be put in the .htaccess file, when you want to force your website visitors to go through SSL:

Solution A:

RewriteEngine On
RewriteCond %{SERVER_PORT} !443$
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R]

Solution B:

RewriteEngine on
RewriteCond %{HTTPS} !^on$ [NC]
RewriteRule . https://%{HTTP_HOST}%{REQUEST_URI} [L]

Pick whatever solution looks nicer for you.