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.

Apache redirect http to https

Discussion in 'General Discussion' started by nasirnjs, Jan 26, 2015.

  1. nasirnjs

    nasirnjs Member

    Joined:
    Jan 14, 2015
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    I have install SSL for my domain. How to Apache redirect http to https on .htaccess file.
     
  2. Jan-Paul

    Jan-Paul Registered

    Joined:
    Mar 24, 2015
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Maarheeze
    cPanel Access Level:
    Root Administrator
    Because the link that cPanelMichael posted did not resolve my issue I want to contribute some information about how I solved this.
    It should be noted that the out-of-the-box solution of cPanel writes some code in the .htaccess file that causes issues. These issues are typed as 'too_many_redirects'.

    The way I solved this is:


    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://www.domain.tld/$1 [R,L]

    It works quite simple by checking if the connection is using SSL/TLS. If it is not (and therefore returns 'off') then it takes action on the rewriterule below it.

    I am aware that not every case is covered with this simple addition but I thought it was useful to add it here because this is where google led me ;-)
     
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    651
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page