Force SSL with mod_rewrite
by sudo on Oct.15, 2009, under Apache, Linux
Create a .htaccess within the document root with the following.
RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
You must ensure AllowOverride is set to All within the apache configuration or it will not read the .htaccess.