Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

SOLVED Setting up redirection for https issue

Discussion in 'Security' started by G. Andore, Jun 6, 2018.

Tags:
  1. G. Andore

    G. Andore Registered

    Joined:
    May 30, 2018
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Guatemala
    cPanel Access Level:
    Website Owner
    Hello Team,

    I've created a redirection on my Cpanel as shown below on the pictures attached but I am getting the error below.

    This page isn’t working
    example.com redirected you too many times.
    Try clearing your cookies.
    ERR_TOO_MANY_REDIRECTS

    I selected this on Cpanel:
    Code:
    Type: permanent 103
    https?://(www.)?: example.com
    Blank space on /
    Redirects to: https://example.com
    Redirect with or without www.
    Selecting Wild Card Redirect.
    
    My goal is that when anyone types
    Code:
     'example.com' or 'www.example.com' 
    they got directly to
    Code:
     https://example.com 
    secured site and it's working good with SSL but I want to fix those 2 addresses. Thanks for the help!
     

    Attached Files:

    #1 G. Andore, Jun 6, 2018
    Last edited by a moderator: Jun 6, 2018
  2. Dave Smith

    Dave Smith Active Member

    Joined:
    Mar 20, 2016
    Messages:
    40
    Likes Received:
    12
    Trophy Points:
    8
    Location:
    Lisbon
    cPanel Access Level:
    Root Administrator
    Hi,
    You could try undoing your changes above and uploading a .htaccess file containing the following (or enter the below in to your current .htaccess file at the top).

    Code:
    RewriteEngine On
    RewriteCond %{HTTPS} off
    # First rewrite to HTTPS:
    # Don't put www. here. If it is already there it will be included, if not
    # the subsequent rule will catch it.
    RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    # Now, rewrite any request to the wrong domain to use www.
    # [NC] is a case-insensitive match
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    See if that helps..?
     
    cPanelMichael and Dan70 like this.
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,672
    Likes Received:
    1,788
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello @G. Andore,

    I recommend trying the recommendation provided by @Dave Smith in the previous post, or trying an example like the one offered on the following thread:

    Force https question

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. Dan70

    Dan70 Member

    Joined:
    May 18, 2016
    Messages:
    19
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    Hamburg
    cPanel Access Level:
    Root Administrator
    thx!! works for me with SuiteCRM
     
    cPanelMichael likes this.
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,672
    Likes Received:
    1,788
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello @Dan70,

    I'm glad to see the issue is now solved. Thanks for sharing the outcome!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. Dave Smith

    Dave Smith Active Member

    Joined:
    Mar 20, 2016
    Messages:
    40
    Likes Received:
    12
    Trophy Points:
    8
    Location:
    Lisbon
    cPanel Access Level:
    Root Administrator
    I can't take credit for the solution. Like many other solutions I came across it on Stack Overflow. If you have time pop over there sign-up and thank 'Michael Berkowski'.

    ;)
     
    cPanelMichael likes this.
  7. G. Andore

    G. Andore Registered

    Joined:
    May 30, 2018
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Guatemala
    cPanel Access Level:
    Website Owner
    Hello @Dave Smith and @cPanelMichael

    I've tried doing what you did but it happened the same issue I mentioned above. ERR_TOO_MANY_REDIRECTS.

    Can you be so kind to take a look on the code I sent below took from my htaccess and let me know if something is wrong. Or should I replace the current values for the ones you've shared?

    Code:
    RewriteEngine On
    RewriteCond %{HTTPS} off
    # First rewrite to HTTPS:
    # Don't put www. here. If it is already there it will be included, if not
    # the subsequent rule will catch it.
    RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    # Now, rewrite any request to the wrong domain to use www.
    # [NC] is a case-insensitive match
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    
    RewriteOptions inherit
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
     
  8. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,672
    Likes Received:
    1,788
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice