I have the following set up for my virtual host:
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
DocumentRoot /var/www/example.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine On
RewriteCond %{HTTPS} Off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
</VirtualHost>
This works fine if I visit http://www.example.com
or http://example.com
. However, if I go to a specific URL like http://www.example.com/docs/
it does not redirect to HTTPS, and will maintain the non-secure connection. Why is this happening?