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.

Two SSL Host in the Cpanel (SSL error)

Discussion in 'Security' started by puspa, Apr 15, 2013.

  1. puspa

    puspa Registered

    Joined:
    Apr 15, 2013
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Hi Friends,

    I need to redirect one domain https://www.mydomain.com to https://mydomain.com. I use this .htaccess and it not work for me.

    Previously i have the ssl cert for https://www.mydomain.com and it was broke, we register the new ssl for the host https://mydomain.com

    In the WHM there is only one ssl host but in the cpanel there are two hosts one is old www.mydomain.com and mydomain.com (Is this effect on the redirection?)

    the .htaccess is below.

    RewriteEngine on

    RewriteCond %{HTTPS} on
    RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$ [NC]
    RewriteRule ^(.*)$ https://mydomain.com/$1 [R=301,L]

    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com$ [NC]
    RewriteRule ^(.*)$ https://mydomain.com/$1 [R=301,L]

    I am getting the security alert always while i type https://www.mydomain.com.

    What the mistake that i did here?

    Thanks in advance :)
     
  2. arunsv84

    arunsv84 Well-Known Member

    Joined:
    Oct 20, 2008
    Messages:
    373
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    127.0.0.1
    cPanel Access Level:
    Root Administrator
    Standard SSL certificate is valid for domainname. com or http://www.domainname. com and that's normal. In your case it seems the certificate was valid for http://www.domainname. com and now the new SSL is generated for domainname. com(without www). You just need to redirect the requests from https://www.domainname. com to https://domainname. com and that should work. You are getting security alert in https://www.mydomain. com because SSL is valid for https://domainname. com(Assuming you have installed SSL correctly on server).
     
    #2 arunsv84, Apr 17, 2013
    Last edited: Apr 17, 2013
  3. quietFinn

    quietFinn Well-Known Member

    Joined:
    Feb 4, 2006
    Messages:
    998
    Likes Received:
    10
    Trophy Points:
    18
    Location:
    Finland
    cPanel Access Level:
    Root Administrator
    Seems you didn't read (or understand) what the OP is asking.
    What you are asking the OP to do is exactly what he is doing, and then you tell that "You are getting security alert ...".

    The OP is getting the security alert because the redirection happens after the connections is made. If the certificate is for domain.com and you are connecting to https://www.domain.com you get the security alert, and after that the connection is redirected to https://domain.com.

    AFAIK the only way to fix that is that the OP gets a certificate that is valid for domain.com and www.domain.com. Many even cheap certificates do that.
     
  4. arunsv84

    arunsv84 Well-Known Member

    Joined:
    Oct 20, 2008
    Messages:
    373
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    127.0.0.1
    cPanel Access Level:
    Root Administrator
    There is nothing to be confused. I just meant to say that OP need to redirect all requests to https:// mydomain .com

    OP already said that he purchased SSL for mydomain. com.

    Its simple. Because the certificate is valid for https://mydomain .com

    Cheers!!!
     
  5. arunsv84

    arunsv84 Well-Known Member

    Joined:
    Oct 20, 2008
    Messages:
    373
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    127.0.0.1
    cPanel Access Level:
    Root Administrator
    Its not required to get a certificate for both domain. com and www. domain .com. Just setting the htaccess rules is enough.
     
  6. quietFinn

    quietFinn Well-Known Member

    Joined:
    Feb 4, 2006
    Messages:
    998
    Likes Received:
    10
    Trophy Points:
    18
    Location:
    Finland
    cPanel Access Level:
    Root Administrator
    The redirection happens after the connection is made, so you still get the security warning.
     
Loading...

Share This Page