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.

Force https question

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

  1. EneTar

    EneTar Well-Known Member

    Joined:
    Dec 19, 2015
    Messages:
    51
    Likes Received:
    1
    Trophy Points:
    8
    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:
    51
    Likes Received:
    1
    Trophy Points:
    8
    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:
    940
    Likes Received:
    55
    Trophy Points:
    28
    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 Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    650
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    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.
     
  5. EneTar

    EneTar Well-Known Member

    Joined:
    Dec 19, 2015
    Messages:
    51
    Likes Received:
    1
    Trophy Points:
    8
    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 Forums Analyst
    Staff Member

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

    EneTar Well-Known Member

    Joined:
    Dec 19, 2015
    Messages:
    51
    Likes Received:
    1
    Trophy Points:
    8
    Location:
    Greece
    cPanel Access Level:
    Root Administrator
    Thank you, good link
     
Loading...

Share This Page