How to use a wildcard SSL Certificate | Bluehost Support
Support
  1. bluehost knowledge base

How to use a wildcard SSL Certificate

Overview

This article will show you how-to use your WildCard SSL Certificate on your Bluehost hosting account using mod_rewrite. This is required due to a limitation in WHM that only allows there to be one virtualhost entry.

Folder Structure

The subdomain must be assigned to a folder that is underneath the folder its parent domain is assigned to. Because of the way subdomains are assigned, it's easy for a subdomain not to be put inside the parent domains folder. You will need to reassign the domain to a folder under the parent domain in this situation.
Example: Say you have a wildcard SSL certificate, for example.com. Example.com is assigned to the public_html folder. I want to use my certificate on sub.example.com. In this case, sub.example.com should be assigned to public_html/sub/ because the sub is a directory underneath public_html.

Accessing the .htaccess File

The .htaccess file is located in the parent domain's folder. While you can use an FTP or an SSH client to access the file, we will be using the File Manager for this article.

  1. Log in to your Bluehost control panel.
  2. Click the File Manager located in the Files section of the cPanel.
  3. Check the box Show Hidden Files (dotfiles).
  4. Right-click the .htaccess file and choose Edit or Code Edit.
  5. Follow the instructions under Generic mod_rewrite Rule for basic HTML sites and copy the code into the Editor. If you have a WordPress, Joomla, or Drupal site, follow the instructions under WordPress/Joomla/Drupal mod_rewrite Rule.
  6. Click Save Changes.

Generic mod_rewrite Rule

If you have a basic HTML site, copy the following text into your public_html/.htaccess file.

Note: You should not use this if you have a WordPress, Joomla, or Drupal site. Use the instructions under WordPress/Joomla/Drupal mod_rewrite Rule instead. You will need to replace the subdomain with your subdomain and example.com with your domain name.

# Bluehost .htaccess WildCard SSL
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain.example.com$
RewriteCond %{REQUEST_URI} !^/subfolder/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /subfolder/$1
RewriteCond %{HTTP_HOST} ^subdomain.example.com$
RewriteRule ^(/)?$ subfolder/index.php [L]

Once you have modified this code, you may need to clear your browser cache to be able to see the redirect.

WordPress/Joomla/Drupal mod_rewrite Rule

For WordPress, Joomla, or Drupal sites, copy the following code:

  • If Just The Subdomain Holds either a WordPress, Joomla, or Drupal Site

    If your subdomain holds either a WordPress, Joomla, or Drupal site, the parent domain does not copy the following code.

    You will need to replace the subdomain with your subdomain and example.com with your domain name.

    # Custom subdomain .htaccess SSL + WordPress
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^subdomain.maindomain.com$
    RewriteCond %{REQUEST_URI} !^/subfolder/
    RewriteRule ^(.*)$ /subfolder/$1
    RewriteCond %{HTTP_HOST} ^subdomain.maindomain.com$
    RewriteRule ^(/)?$ subfolder/index.php [L]
    # End custom subdomain .htaccess
  • If The Parent Domain has WordPress

    If both the parent domain and the subdomain have either a WordPress, Joomla, or Drupal site, copy the following code into your .htaccess file. This code will replace the WordPress permalink code.

    You will need to replace subdomain with your subdomain and example.com with your domain name.

    # Custom subdomain .htaccess SSL + WordPress
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^subdomain.maindomain.com$
    RewriteCond %{REQUEST_URI} !^/subfolder/
    RewriteRule ^(.*)$ /subfolder/$1
    RewriteCond %{HTTP_HOST} ^subdomain.maindomain.com$
    RewriteRule ^(/)?$ subfolder/index.php [L]
    # End custom subdomain .htaccess
    
    # Custom maindomain .htaccess WordPress
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^(www.)?maindomain.com$
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{HTTP_HOST} ^(www.)?maindomain.com$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    # End custom maindomain .htaccess

You may need to clear your browser cache for the new rules to work. After that, your Wildcard SSL certificate should be working.

Wildcard Subdomains or DNS

Bluehost does support the creation of Wildcard DNS/Subdomains. To create them, follow these steps:

  1. Log in to your Bluehost Control Panel
  2. Click the Subdomains icon located in the Domains section.
  3. In the "Subdomain" name field, enter the "*" character. (Shift + 8)
  4. Leave the "Document Root" set to default.
  5. Select Create.

After this has been done, the record will be added to your domain's DNS entry. You can then look up any properly formed subdomain and have it resolved. Note: Occasionally a subdomain can take a couple of hours to propagate.

If you would like to create a redirect for this subdomain so that every subdomain gets redirected to www for instance, you can modify the following lines of code and insert it into the .htaccess file found in the public_html/wildcard folder.

RewriteEngine on
RewriteBase /
#for all requests on mydomain.com
RewriteCond %{HTTP_HOST} mydomain\.com$ [NC]
#if they are not for the www.mydomain.com
RewriteCond %{HTTP_HOST} !^www\.mydomain\.com$ [NC]
#301 redirect to www.mydomain.com
RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L]

You can use the file manager to edit the .htaccess file To get to the file manager, go to the cpanel, scroll down to the files section, and then click on file manager. Select the option for webroot and show hidden files, then press go. Once you see the contents of the public_html/wildcard folder on the right of the screen, right-click the .htaccess file and select edit, then press edit again. Put the code at the top of the .htaccess.

If you need further assistance, feel free to contact us via Chat or Phone:

  • Chat Support - While on our website, you should see a CHAT bubble in the bottom right-hand corner of the page. Click anywhere on the bubble to begin a chat session.
  • Phone Support -
    • US: 888-401-4678
    • International: +1 801-765-9400

You may also refer to our Knowledge Base articles to help answer common questions and guide you through various setup, configuration, and troubleshooting steps.