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 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 Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    45,725
    Likes Received:
    1,992
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    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 Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    45,725
    Likes Received:
    1,992
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    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 Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    45,725
    Likes Received:
    1,992
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    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.
  8. theluli

    theluli Member

    Joined:
    Nov 19, 2015
    Messages:
    10
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    Kosovo
    cPanel Access Level:
    DataCenter Provider
    Hi Giovanni

    Where you add this "domain" does has to be a real domain name and second , you need to add for all domains ?
     
  9. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    45,725
    Likes Received:
    1,992
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello @theluli,

    Yes, it should be a real domain name. You should only have to add it to the document root of the domain name you want redirected.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  10. theluli

    theluli Member

    Joined:
    Nov 19, 2015
    Messages:
    10
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    Kosovo
    cPanel Access Level:
    DataCenter Provider
    Thanks man, that helped a lot
     
    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