Force the page to always use HTTPS

The code below in .htaccess gives the wanted result

1
2
3
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]