Redirecting all users to https with apache and without .htaccess

This is more a note to myself, but while enabling a certificate on one server I came upon this little snippet to redirect all http access to the secure https:

[code]RewriteEngine On
# This will enable the Rewrite capabilities

RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS

RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
# This rule will redirect users from their original location, to the same location but using HTTPS.
# i.e. to
# The leading slash is made optional so that this will work either in httpd.conf
# or .htaccess context[/code]

I added this to each virtual host entry.