Skip to main content

HTTPS Redirection For All VirtualHosts

Comments

7 comments

  • THawke
    Forgot to mention that I'm using the LetsEncrypt autossl provider, I'm not sure that would affect anything. Using apache and cpanel config defaults and going to an accounts cpanel and adding a redirect from / to
    0
  • cPanelMichael
    Hello, Rather than using a custom template, you can add the custom redirect rules using the "Apply to all virtual hosts on the system" instructions at: Modify Apache Virtual Hosts with Include Files - EasyApache 4 - cPanel Documentation Thank you.
    0
  • THawke
    Putting
    RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTPHOST}%{REQUESTURI}
    into a file at the specified path is working as expected. Thanks.
    0
  • THawke
    Alright, never mind, it's still not functioning properly. Without the configuration I can request a test domain with a "Hello World" index page with CURL from both http and https. When I add this configuration
    RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTPHOST}%{REQUESTURI}
    in /etc/apache2/conf.d/userdata/std/2_4/redirect.conf, I can request the file via curl from https directly okay, but when I request the http, I get curl: (47) Maximum (50) redirects followed. Fresh vps and cpanel, only added a test account. OS CENTOS 6.9 x86_64 cPanel & WHM 64.0
    0
  • cPanelMichael
    Hello, Could you open a support ticket using the link in my signature so we can take a closer look? You can post the ticket number here so we can update this thread with the outcome. Thank you.
    0
  • THawke
    Support request ID: 8626835
    0
  • THawke
    Putting:
    RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
    In a .conf file under /etc/apache2/conf.d/userdata works well. There was also an issue with CloudFlare proxy that was not requesting via http so https requests would come back with the redirect to http causing the loop.
    0

Please sign in to leave a comment.