Skip to main content

Force HTTP Redirect - from WHM?

Comments

21 comments

  • cPRex Jurassic Moderator
    Hey there! Currently there is not a way to do this from the WHM level, although that sounds like a great feature request to submit using the link in my signature below. The redirect button only appears if the domain has an SSL installed. Since the AutoSSL installation doesn't happen instantly when the account is created, as active DNS is required for AutoSSL to run, there isn't a way to ensure that is turned on by default at the time the account is created.
    0
  • tptompkins
    Thank you for the info. However, I'm having an issue how where if I turn on Force HTTPS Redirect from the Domains section inside cPanel, within a couple minutes of doing this the site starts producing "too many redirects" errors: ERR_TOO_MANY_REDIRECTS If I turn off force https redirect, it starts working fine again. This is only happening with one specific account on my server and I'm not sure why. Any ideas? Thanks, Tommy
    0
  • kodeslogic
    Can you let us know the contents of the .htaccess file by replacing references to real domain names with examples
    0
  • tptompkins
    Can you let us know the contents of the .htaccess file by replacing references to real domain names with examples

    I have my hosting provider (LiquidWeb) working on it but they can't seem to figure it out. They ended up putting their own .htaccess file on the account which seems to help but then I'm not using the switch inside cPanel and force https redirect is turned off. This is what they have in there now: #RewriteEngine On #RewriteCond %{HTTP_HOST} !^www\. #RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] #RewriteCond %{HTTPS} off #RewriteCond %{HTTP:X-Forwarded-Proto} !https #RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] But I just checked and it's still not working. You can try yourself by trying to load [REDACTED]
    0
  • tptompkins
    Now LiquidWeb is telling me that it has something to do with CloudFlare and they pointed me to this:
    0
  • kodeslogic
    Yes, I can see you are using Cloudflare so you may have settings enable for HTTPS rewrite there as well. Try commenting: RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    and turn off "Force HTTPS Redirect" from cpanel interface. let me know how it goes.
    0
  • tptompkins
    I turned off force https redirect inside cpanel and have this for my .htaccess file contents but I still get too many redirects. If I remove the .htaccess file it loads fine. #RewriteEngine On #RewriteCond %{HTTP_HOST} !^www\. #RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] #RewriteCond %{HTTPS} off #RewriteCond %{HTTP:X-Forwarded-Proto} !https #RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    0
  • kodeslogic
    I think you have taken corrective steps as I see the concerned subdomain loading fine :)
    0
  • tptompkins
    I think you have taken corrective steps as I see the concerned subdomain loading fine :)

    Yes and no because I'm back to where I originally started. I want to force https redirects but I still can't :/
    0
  • cPRex Jurassic Moderator
    Is your site using any tools like WordPress or other CMS software? If so, it's often best to handle the redirection with a plugin designed for that specific software to avoid redirection errors.
    0
  • kodeslogic
    When I browse your concerned sub-domain without https I am landing to
    0
  • cPRex Jurassic Moderator
    The subdomain is also loading normally for me at this time, as I get taken to a page with what seems like 11 photo albums.
    0
  • tptompkins
    Is your site using any tools like WordPress or other CMS software? If so, it's often best to handle the redirection with a plugin designed for that specific software to avoid redirection errors.

    Nope, no Wordpress. Just RedCart which is a gallery / shopping cart app for pro photographers. (I'm the developer)
    0
  • kodeslogic
    Please check the attached file, this is what I am able to load in my browser without any "too many redirects" error (site loads with https). I have checked this in chrome as well as in firefox. I have masked the website related to information in the screenshot.
    0
  • cPRex Jurassic Moderator
    ^^^That's what I'm getting at this point as well. If you get a "Too many redirects" error once you have the .htaccess file in place, there is either an issue in that file or a complication between the .htaccess and your site's software.
    0
  • tptompkins
    Thanks guys. What you're seeing is working because I have the .htaccess file disabled at the moment. If I turn it back on, the too many redirects error comes back. We can access the site with https:// and http:// without the .htaccess file. But when we force redirect from cpanel where it creates the .htaccess file automatically, that's when the issue comes back. At this point I'm thinking it some sort of issue with CloudFlare. The exact same application code works fine with hundreds of other photographer's websites. The only difference is how this particular customer pointed their sub domain to their cpanel account on my server. I don't know anything about how CloudFlare works, so I don't know how to instruct my client to fix the issue on her end. She had her "website people" set it up originally so she doesn't even know what CloudFlare is. If any of you have any other ideas, I'm all ears. Thanks again for the help!
    0
  • kodeslogic
    Cloudflare has its own option to redirect all requests with scheme "http" to "https", which in your case I suspect is on. Please check the screenshot for more details. You will have to either use Cloudflare option or the cPanel option to "Force HTTPS Redirect". If you do not have access to your client's Cloudflare account then consider disabling the cPanel option "Force HTTPS Redirect" for this domain and the below lines can be commented. RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    0
  • Rodrigo Gomes
    Thank you for the info. However, I'm having an issue how where if I turn on Force HTTPS Redirect from the Domains section inside cPanel, within a couple minutes of doing this the site starts producing "too many redirects" errors: ERR_TOO_MANY_REDIRECTS If I turn off force https redirect, it starts working fine again. This is only happening with one specific account on my server and I'm not sure why. Any ideas? Thanks, Tommy

    Hi @tptompkins, this is a cPanel bug when your customer uses this option in conjunction with Cloudflare in Flex mode. When activating the "Force HTTPS Redirect" option in cPanel, the customer's website enters a redirection loop (ERR_TOO_MANY_REDIRECTS). This is because the redirection rule that cPanel create does not take X-Forwarded-Proto into account, which is sented by all reverse proxies and is extensively documented. More about it can be read here: CPANEL-36901. @cPRex Could you follow this up for us and update this page if it has any updates? Thank you.
    0
  • cPRex Jurassic Moderator
    @Rodrigo Gomes - it looks like that case was just created yesterday to bring this to the attention of our development team, so I don't have any updates yet. I'll be sure to post again once I hear something!
    0
  • cPRex Jurassic Moderator
    Update - case CPANEL-36901 will be resolved in an upcoming version 98 build, although it hasn't been assigned a specific version number just yet.
    0

Please sign in to leave a comment.