1. bluehost knowledge base

What Is A Subdomain And How Does It Work? How To Create A Subdomain

What is a Subdomain

A subdomain is a prefix added to your original domain name, like a domain within a domain, usually following the form subdomain.example.com.  They behave very similarly to an addon domain and are often created to separate different sections of your website, such as blog.example.com or store.example.com.  You can point them to a folder to host a website, just like a normal domain name.
 

Accessing the Subdomain Menu

Legacy

  1. Log in to your Bluehost cPanel account.
  2. Click the Domains tab at the top of your account.
  3. Click On Subdomains on the submenu.

Rock

  1. Log in to your Bluehost account.
  2. Click the Domains tab from the side navigation to the left.
  3. Click on Subdomains from the drop-down menu that appears.

Creating a Subdomain

  1. Enter the desired subdomain
  2. Choose one of your Domain Names from the drop-down list.
  3. Enter the Document Root (this is the folder that contains the website you want to show).
  4. Click Create.

Hosting Only A Subdomain

  1. In Bluehost, create the account with the domain name you purchased elsewhere. **Example** If you are setting up the domain "subdomain.example.com", sign up your account with the name as "example.com"
  2. In your Bluehost cPanel, create the subdomain you need to host with us, (ie: "subdomain.example.com" .)
  3. Contact the host of your domain name's zone file and have them point the A record for the subdomain to the IP of your Bluehostserver.
This should take somewhere between 24 to 72 hours to propagate and your subdomain will be live on our servers.

Restrict Subdomain Access to Addon Domains

Each Addon Domain requires a subdomain. Using mod_rewrite you can stop people from being able to use the addon domain as a subdomain of the primary domain

Put this in the .htaccess file located at the subdomains folder, changing the subdomain, primarydomain.com, and addondomain.com:
 
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain.primarydomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.subdomain.primarydomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^addondomain.com$
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ http://www.addondomain.com/ [R=301,L]