How to force using an SSL connection on a website?

If you want to force using an SSL connection, create or edit a file with the name ".htaccess" in your domain's main folder and put the following content into it:

RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule . https://%{HTTP_HOST}%{REQUEST_URI} [L,NE]

 

Note: If you have an existing .htaccess file, please always make a backup copy before editing it, to be able to restore it, if you make a mistake.