Redirect to the HTTPS version of a page

I often have the problem that a client wants their customers to login on a secure site. The following .htaccess files are a simple way of accomplishing this by redirecting the the sercure version.

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

If that doesn’t work, try this:

RewriteEngine On
RewriteCond %{SERVER_PORT} !443
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R]