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!

http to https redirect

Discussion in 'Security' started by 'Giovanni, Dec 4, 2017.

  1. 'Giovanni

    'Giovanni Member

    Joined:
    Feb 13, 2008
    Messages:
    9
    Likes Received:
    1
    Trophy Points:
    51
    i want to redirect all http non www and www to https with www, for example
    Code:
    domain.com to https://www.domain.com
    www.domain.com to https://www.domain.com
    https://domain.com to https://www.domain.com
    
    anyone can help?
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,728
    Likes Received:
    1,796
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. 'Giovanni

    'Giovanni Member

    Joined:
    Feb 13, 2008
    Messages:
    9
    Likes Received:
    1
    Trophy Points:
    51
    Code:
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$ https://www.domain.com/$1 [R,L]
    
    i've used this one but it has no effect.
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,728
    Likes Received:
    1,796
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. 'Giovanni

    'Giovanni Member

    Joined:
    Feb 13, 2008
    Messages:
    9
    Likes Received:
    1
    Trophy Points:
    51
    same, it wont work.
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,728
    Likes Received:
    1,796
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    Could you post the contents of the .htaccess file you tried using, ensuring to replace real domain names with examples?

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. 'Giovanni

    'Giovanni Member

    Joined:
    Feb 13, 2008
    Messages:
    9
    Likes Received:
    1
    Trophy Points:
    51
    my .htaccess was empty.
    i put the code that was specified in your links and replaced domain.com with my real domain.

    for now i've found a working solution:
    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
    RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
    
    i'm not sure if this is correct but it gets the job done, it points all my non https with or without www to ssl with www.
     
    cPanelMichael likes this.
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