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!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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:
    41,396
    Likes Received:
    1,606
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
  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:
    41,396
    Likes Received:
    1,606
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
  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:
    41,396
    Likes Received:
    1,606
    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.
     
  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