I often find myself Googling apache config snippets and now that I’m managing a server myself, HTTPS is useful pretty much everywhere. Here is a rewrite that will work in either .htaccess or a vhost declaration to redirect traffic to HTTPS with minimal URL hard-coding.
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L] </IfModule>