Please Read Before Creating a Subdomain
When you create a subdomain in cPanel, you will be asked to choose the subdomain's name, the domain the subdomain is for, and the location from which the new subdomain will load its content.
Here is a list of terminologies used in this article.
- Domain name - A domain identifies your website in the world-wide-web.
(Reference: What Is a Domain Name? (Blog))
- Subdomain name (or simply subdomain) - A subdomain is a prefix added to the main domain to easily organize and navigate the website. For example, your website is "snappygator.com," while your shop (or subdomain) could be "shop.snappygator.com."
(Reference: What is a Subdomain Name & How to Create One)
- Document root - This is also known as web server document root. It is a folder where the website files are kept on the server. Each domain name has its unique folder on the server.
(Reference: What is a Document Root Folder?)
Document root directories for subdomains
If you have addon domains or parked domains in which you want to have the same subdomain name with different content, pay close attention to the Document Root field when creating a subdomain.
When creating subdomains in cPanel, the Document Root field auto-populates with a new folder or directory name. This directory will "house" the contents of your subdomain. Remember that a subdomain is an addon to your main domain, a "sub-portion," so to speak. It operates under the same main domain but gets to have its own identity because of the contents inside its own document root.
Why document root directories cannot be the same
This is very important because if you create "blog.snappygator.com" and "blog.example.com" on the same cPanel and leave the Document Root fields as what the cPanel suggested, both of your blogs (subdomains) will load from the same directory of /public_html/blog. You will not have separate content for each subdomain.
As shown in the image above, when you access the websites blog.snappygator.com and blog.example.com, both will show the same content as they both have the same document root directories.
If you own several domains and wish to have a different blog set up for each domain that loads from the subdomain name "blog," you will have to change each domain's document root.
How to avoid duplicate document root directories
To avoid having duplicate document root directories 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, you will have more than one domain using "blog" as a subdomain, but both subdomains will be loading separate content.
The image above shows that blog.snappygator.com and blog.example.com have their own document root directories, thus, making them display their own separate website contents.