I have this apache config:
<VirtualHost *:80>
DocumentRoot "/home/example/public_html/"
ServerName www.example.com
<Directory "/home/example/public_html/">
allow from all
RewriteEngine on
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
</Directory>
</VirtualHost>
The redirect never seems to fire and just serves files from http. I've tried all sorts of combinations, but nothing seems to work.
mod_rewrite is enabled (using LoadModule rewrite_module modules/mod_rewrite.so)
Can anyone help?
Best Answer
This is way overcomplicated. You only need two (or three) directives to redirect everything to HTTPS, e.g.
This will redirect both with and without
www
to the canonical HTTPS site.