The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Can't get my site to redirect to https?

Discussion in 'Security' started by opentoe, May 22, 2015.

  1. opentoe

    opentoe Active Member

    Joined:
    Feb 6, 2013
    Messages:
    40
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Website Owner
    I have a legit SSL cert for my site. If I use https it works fine. No errors or warnings. All good. But when I use http it doesn't redirect to https. So I went into my cpanel and setup a perm redirect to https but when I did that Google Chrome complained there was a redirect loop and wouldn't display the page at all. Soon as I removed the redirect it goes back to the same thing as before. I don't want anyone to use http at all, only https. Is there a way to only get https working and ALWAYS redirect to https? I even tried to edit my .htaccess file itself and a redirect error/loop came back again from Chrome. Internet Explorer just wouldn't display anything. Maybe there is a setting in WHM/CPANEL for this?

    Thanks.
     
  2. LostNerd

    LostNerd Well-Known Member

    Joined:
    Mar 12, 2014
    Messages:
    258
    Likes Received:
    11
    Trophy Points:
    18
    Location:
    Hastings, East Sussex, UK
    cPanel Access Level:
    Root Administrator
    Twitter:
    Code:
    RewriteEngine On
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
    
    Pop that in /home/$username/public_html/.htaccess - That'll redirect any traffic on port 80 (HTTP) to HTTPS. :)
     
  3. opentoe

    opentoe Active Member

    Joined:
    Feb 6, 2013
    Messages:
    40
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Website Owner

    As I said this is what I get when I edit my .htaccess file with that.

    The webpage at https://www.<domain>.com/index.php has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer.
     
  4. opentoe

    opentoe Active Member

    Joined:
    Feb 6, 2013
    Messages:
    40
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Website Owner

    EDIT: Well, I found out what the problem was. The installed front end program that was running had a check mark to use https or http and that wasn't checked. Soon as I checked https only it must have made some change in my htaccess file because now I can only access https now.
     
  5. LostNerd

    LostNerd Well-Known Member

    Joined:
    Mar 12, 2014
    Messages:
    258
    Likes Received:
    11
    Trophy Points:
    18
    Location:
    Hastings, East Sussex, UK
    cPanel Access Level:
    Root Administrator
    Twitter:
    Looks more like the script (I assume PHP) looks for whether you specify HTTP of HTTPS and then does a redirect dependent on the protocol in use. It ideally shouldn't touch your .htaccess :)

    Without posting your .htaccess file here, there was no way for me to know that the script I provided was what you had. It's always best to provide examples where possible. We can only help as far as the information that is provided.

    I'm glad you solved the problem.
     
    #5 LostNerd, May 23, 2015
    Last edited: May 23, 2015
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,675
    Likes Received:
    648
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello,

    I am happy to see the issue is now resolved. Thank you for updating us with the outcome.
     
Loading...

Share This Page