redirecting all HTTP requests to HTTPS by RedirectMatch

Apache’s Redirect directive may not help you if you are using multiple server-names if you want to redirect all HTTP requests to SSL. In this case you can use RedirectMatch directive which doesn’t have enough example on its documentation. By adding this line just below your ServerName definition in your httpd.conf, you may easily do redirection. Enjoy!

RedirectMatch “http://(.*)” “https://$1”

mod_rewrite is still a powerful alternative, so;

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