How to Create a SubDomain in cPanel

Before we tae you through the steps involved in creating a subdomain, it is good to give you some background knowledge of what a subdomain really means.
 
A subdomain is an Internet domain which is part of a primary domain. A domain that is a part of another (main) domain. For example, blog.example.com and clients.example.com/ are subdomains of example.com

Note: Some subdomain names are reserved: mail, www, ftp, cpanel, whm, webmail and webdisk. You can use any name except these names.

When you create a subdomain in cPanel, the first thing you will have to do is to choose the name of the subdomain, the domain the subdomain is for and the location from which the new subdomain will load it's content.

How to Create a Sub-Domain

 
To create a subdomain, you will have to follow these steps:
 
Log into cPanel and click on the "Subdomains" icon.
In the "Subdomain" field, please select the name of the subdomain which you wish to use, for example, you might choose "blog". If you choose blog, then your subdomain will look like "blog.example.com".

Next, select the desired domain you wish to create this subdomain for from the drop down menu to the right of the "Subdomain" field. You may create a subdomain for any addon, parked or subdomain that already exists in your cPanel.

When you click on the "Document Root" field, it should automatically populate with a cPanel suggested location from which the subdomain will load it's content. For instance, if you chose "blog" as your new subdomain, then the "Document Root" field will populate with "/public_html/blog". This means that the new subdomain will load it's content from the folder named "blog" from within the "public_html" directory.


Note: The temporary URL for a subdomain is

http://ipaddress/~username/subfolder/ or http://servername/~username/subfolder/

where the username is your cPanel user name for your primary domain.

Examples

http://sub123.todhost.com/~username/addon.com/

http://sub123.todhost.com/~username/subdomain/


If you have an addon or parked domains that you wish to have the same subdomain name for, but wish for those subdomains to load different content, then you must pay close attention to the "Document Root" field. For example, if you own several domains and wish to have a different blog set up for each domain that loads from the subdomain name blog, then you will have to change the "Document Root" of each domain that you set up. This is very important because if you create blog.todhost.com and blog.seohosting.com on the same cPanel, but leave the "Document Root" as the cPanel suggested location, then both of your blog subdomains will load from the same directory of "/public_html/blog" and you will not have separate content for each subdomain.
 
To avoid experiencing this issue, when you create your new subdomain, make sure you set the "Document Root" to something other than "/public_html/blog", instead, set it to something like "/public_html/blog1". If you have done this correctly, then you will have more than one domain using "blog" as a subdomain, but both subdomains will be loading separate content.

Also read:

How to Reset or Change to a New CPanel Password
How to Set Up and Delete a Cron Job
How to Setup Google Apps MX, CNAME and SPF records
How to upload files to a website
Overview of Quickinstall

When to Use a Subdomain

Subdomains enable you to set up multiple websites using a single domain. However, you can actually use subdirectories to achieve the same end, for example by setting up a todhost.com/blog subdirectory. But there are reasons and times we recommend a subdomain instead of a sub-directory.

  • Search engines recognize subdomains as individual websites. That means you get more chances to increase your traffic.
  • They enable you to set up backlinks to your primary domain, which can increase its authority.
  • When you are running an e-commerce store to complement your primary website.
  • When you are setting up a blog for an existing company or business website.

These two situations have one thing in common: they’re both running as parallel sites with specific functionality. You can achieve the exact same results using subdirectories, but the SEO benefits often make subdomains a better choice.

How to create wildcard sub-domains in cpanel

Wildcard subdomains will allow you to point all your subdomains ( both existing and non-existing ) to a specific folder in your account. What this means is that if you enter any subdomain in your browser ( wether existing or not), it will show the same content that you uploaded to the folder for the wildcard subdomain.

In order to create a wildcard subdomain, please, follow these steps:

n order to create a wildcard subdomain, follow the next steps:

1. Log into your cPanel. You will be able to login with the right credentials namely your username and password. If you have forgotten your password, then use the password recovery link to reset your password.

2. Navigate to the menu Subdomains under the Domains section:


3. Create a subdomain * pointing it to the necessary folder (you will need to specify the path in the field Document Root):


4. Go to the menu Advanced DNS Zone Editor :


5. Make sure that there is an A record for *.yourdomain.com created and pointed to the server IP address (it could coincide with the IP address of your main domain or ftp.yourdomain.com is pointed to):


6. Now, you will need to wait until the propagation is over For this A record; you can edit it manually and reduce the number to speed up the process), and then the wildcard subdomain will work correctly.

The URLs and the navigation structure of a website can affect a website's search engine optimization. For example, take sub domains and sub directories. These are site's structural elements that do influence how Google ranks results. While the difference between when a page is in a sub directory (also called a sub folder) vs when it's on a sub domain might not be always huge, there are cases when it really matters if you use sub domains or sub directories. In this article, we examine the difference between a sub domain and a sub directory.

Also read:

PHP Configuration in cPanel
Step by Step Approach to Password Protect a Directory in cPanel
The htaccess file and its uses


How to change a subdomain's website folder

A sub-domain is a website that is located somewhere outside of the root directory. This means that you will have something like subdomain.yourdomain.com. Sub-domains are treated separately by search engines from the root domains like yourdomain.com or www.yourdomain.com. This stand alone or separation is one of the major reasons why some companies and webmasters would want to use the sub-domain option when they want to separate websites that are not directly related or to set up sections of a website such as a blog or forum.

Why Change a Sub-Domain's Root Folder

When you create a sub-domain, you certainly give it a name. Let us assume you call webdesign.todhost.com. For some reasons, you could want to change the name of this sub domain. Let us assume you want to shorten the name to designs.todhost.com Your reason for doing this could just be that the new name is short and simple to memorize but having decided to make the change, you also need to change the root folder of your sub-domain.

In this article, we are going to show you how to change your subdomains document root. You will follow these steps to make the changes.

How to Change a Sub-Domain's Root Folder

You will first need to login to cpanel and then continue with the rest of the tutorial.

1) Click the subdomains link found in the Domains section of the panel.

2) Click the Edit button for the domain you wish to modify.

3) Enter the new Document Root you wish to use

4) Click Change

Please note that your website files will NOT be moved when you change the website folder. You will need to use a FTP client, SSH client or the File Manager to move the files to the new location.

The Difference Between a Sub Domain and a Sub Directory

Basically, when you use sub domains, your URLs will look like this:

subdomain.domain.com

Notice the 'subdomain' part before your main domain name. This part tells Google and your visitors that the contents in the sub domain is separate from the contents of the rest of your site. A typical use for sub domains is for a business site where the blog is separate from the rest and it resides on a subdomain of its own – i.e. blog.domainname.com. Sites with forums (and other content, for instance articles) also frequently separate the forum part on a sub domain, such as forum.todhost.com.

Unlike sub domains that precede the domain name, sub directories will look like this:

domain.com/subdirectory

Obviously, the difference is that the directory name comes after the domain name rather than preceeding it as we saw with a sub domain.

There isn't a rule when to use sub domains and when to use sub directories but basically if the content is a good candidate for a separate site, then you go with sub domains. If the content isn't that much different from the main content, you go with sub directories. For instance, if you have a blog about web design, you can have separate sub directories for tutorials, free stuff, your artwork, etc., but put the shop where you sell templates and designs on a separate domain.

How to upload to a sub-domain or addon domain.


Option 1
 
In a FTP client enter this information.

Host = add on domain name
User = addondomain@primarydomain.com
Password = what you entered during Addon domain creation
Port = 21

Once you have successfully connected to your ftp client will be in the root of the add on domain name.

If everything was successful you should see a folder called cgi-bin.

Upload your files.

Enjoy your new site.

Option 2
 
In a FTP client enter this information.

Host = primary domain name
User = cPanel username
Password = cPanel password
Port = 21

Once you have successfully connected to your ftp client will be in the home directory.

Double click the public_html folder. Double click the addon domain folder.

Upload your files.

Enjoy your new site.
You do not need to upload or create the cgi-bin folder. The cPanel will automatically create this folder with each new Addon and Subdomain creation.
  • 12 Users Found This Useful
Was this answer helpful?

Related Articles

I have a full backup of account through cPanel. How do I restore it?

It is recommended that you maintain healthy backup of your website and possibly download the...

How To Create, Edit, and Delete a File in cPanel Using File Manager

This tutorial will be useful for you to understand how to create a file, edit a file or delete...

How to Create and Manage a MySQL Database

Create MySQL Database and User via cPanel The MySQL Database Wizard is another useful tool...

How do I create and remove an Addon Domain?

An add-on domain is a separate domain name that you add to your web hosting subscription with...

How to Set Up and Delete a Cron Job

A cron job allows you to run a certain command at times set by the job. For example, you could...