Looking for a way to redirect http traffic to https across all VirtualHosts by default. To try to accomplish this I've copied vhost.default to vhost.local in /var/cpanel/tempaltes/apache2_4 and have added various methods for redirection to the bottom of the vhost template including:
and
I have tried a few different Rewrite rules to try to get it to work. However, whatever I use seems to redirect to an https url okay, but is creating a redirect loop. It appears to be generating the correct configuration in httpd.conf according to the documentation I've read, so I'm not sure where the redirect loop is coming from. It's a freshly spun up VM, everything is default other than a few imported cpanel accounts for testing and the vhost redirection snippet I'm trying to inject via the template.
Code:
Redirect / https://[% wildcard_safe(vhost.servername) %]/
Code:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}