Installing A Wildcard SSL Certificate In cPanel
Installing a wildcard SSL certificate on cPanel is not the easiest thing in the world, and once you do have it installed, being able to actually take advantage of the wildcard feature can be troublesome.
Depending on who you ask, some people will tell you that you need a dedicated IP address for every subdomain you want to have the SSL installed on, that manual edits to the httpd.conf file are required, or that you should have no problem adding subdomains and have them work with HTTPS.
The problem is, this isn't the case. So here's how to actually install a wildcard SSL on cPanel.
First, you need to generate a CSR. When it asks for the hostname (the domain), you'll enter the following:
*.yourdomain.com
Once the CSR is generated, go ahead and purchase your SSL certificate.
When you receive the certificate key, you can now install the certificate. You'll need the following:
- Certificate Key
- Private RSA Key
- CA Bundle (optional)
Both the Certificate Key and CA Bundle are provided after you order the SSL certificate and it's been approved. The Private RSA Key is provided when you generate the CSR.
Normally, when you install an SSL certificate, it fills in the domain name, IP address, and username. However, for a wildcard SSL in cPanel, you will need to change the domain name to the following:
domain.com
Basically, you're removing the asterisk and period before the actual domain name.
Now, in doing this, when cPanel generates the block of code in the httpd.conf file, it's going to set the document root to the following:
/home/<username>/public_html
And that's ok, but if you want to setup subdomains outside the public_html directory, then the wildcard SSL won't work unless you manually modify the httpd.conf file, which you really don't want to do.
So, to get around this, we need to use mod_rewrite to redirect requests to the appropriate directory.
When you actually set up a subdomain, you can set the path to the folder, and it's probably best to do something like this:
/home/<username>/public_html/subdomains/<subdomain>
In the .htaccess file in your public_html directory, for each subdomain that needs an SSL certificate, you will need to add the following:
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{HTTP_HOST} ^sub\.domain\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/subdomains/sub/
RewriteRule ^(.*) /subdomains/sub/$1
You'll want to replace sub with the appropriate data, of course.
If you're using Magento, you don't have to do the above, simply setup additional stores as parked domains, following the instructions outlined here.
And that's all there is to it!
Related Articles
Sorry, no related entries exist for this article.