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!

Force https question

Discussion in 'Security' started by EneTar, Dec 29, 2015.

  1. EneTar

    EneTar Well-Known Member

    Joined:
    Dec 19, 2015
    Messages:
    137
    Likes Received:
    9
    Trophy Points:
    18
    Location:
    Greece
    cPanel Access Level:
    Root Administrator
    I 've read that SSL handshaking takes place before rewrite rules in htaccess and I though to use something like

    Code:
    NameVirtualHost se.rv.er.ip:443
    <VirtualHost se.rv.er.ip:443>
       ServerName www.mydomain.tld
       Redirect permanent / https://mydomain.tld/
    </VirtualHost>
    I've seen some people doing something similar Nginx: redirect non-www to www on https in nginx

    and I thought if there is a way to do this in apache. Of course I tried the above code but I'm definitely no expert at this. Does anybody know how to do it?
     
  2. EneTar

    EneTar Well-Known Member

    Joined:
    Dec 19, 2015
    Messages:
    137
    Likes Received:
    9
    Trophy Points:
    18
    Location:
    Greece
    cPanel Access Level:
    Root Administrator
    Thank you for your answer, I've just tried but it doesn't redirect from https://www. to https://mydomain before it fail in the SSL handshake. I guess it can not be done.
     
  3. quizknows

    quizknows Well-Known Member

    Joined:
    Oct 20, 2009
    Messages:
    1,011
    Likes Received:
    88
    Trophy Points:
    78
    cPanel Access Level:
    DataCenter Provider
    This is what I use to force https in .htaccess:

    Code:
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L]
    
     
  4. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,805
    Likes Received:
    1,898
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello :)

    Most SSL providers allow "non-www" and "www" to work on a default SSL certificate purchased. Is this not the case with your certificate, or are you attempting to redirect between different domain names?

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. EneTar

    EneTar Well-Known Member

    Joined:
    Dec 19, 2015
    Messages:
    137
    Likes Received:
    9
    Trophy Points:
    18
    Location:
    Greece
    cPanel Access Level:
    Root Administrator
    I purchased a multidomain certificate and didn't know that choosing mydomain.com doesn't cover www.mydomain.com. They need $25/domain to cover all the www versions. So I wanted to redirect the traffic from www to non www through https but I suppose this is not going to happen because of the the ssl handshake taking place before the redirects.. I'm not sure if a reverse proxy in the front could help.
     
  6. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,805
    Likes Received:
    1,898
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    Spork Schivago likes this.
  7. EneTar

    EneTar Well-Known Member

    Joined:
    Dec 19, 2015
    Messages:
    137
    Likes Received:
    9
    Trophy Points:
    18
    Location:
    Greece
    cPanel Access Level:
    Root Administrator
    Thank you, good link
     
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