What Are Subdomains and How Do They Work? Print

  • subdomains, cpanel, dns, domain management, website organization, document root, wildcard subdomain, hosting setup
  • 0

A subdomain is a prefix added to your main domain name that creates a separate section of your website. For example, if your domain is example.com, you can create blog.example.com or shop.example.com. Subdomains function as independent websites with their own content and directories, while remaining part of your primary domain.

OBHost customers can create and manage unlimited subdomains through cPanel's Subdomains interface. Each subdomain gets its own directory on your server and can host completely different content from your main website.

Understanding Subdomains

Subdomains use a prefix in conjunction with your domain name to create a unique web address. The subdomain points to a specific folder (document root) on your hosting account, typically within your public_html directory or account home directory.

Common uses for subdomains include:

  • Creating a blog at blog.yoursite.com
  • Setting up an online store at shop.yoursite.com
  • Building a support portal at help.yoursite.com
  • Testing new features at staging.yoursite.com
  • Hosting member areas at members.yoursite.com

Important: DNS changes can take 24 to 48 hours to propagate across the internet. Visitors may not be able to access your new subdomain immediately after creation.

How to Create a Subdomain in cPanel

Follow these steps to create a subdomain through your cPanel account:

  1. Log into your cPanel account
  2. Navigate to the Domains section and click Subdomains
  3. Enter your desired prefix in the Subdomain text box (for example, enter "blog" to create blog.yoursite.com)
  4. Select the main domain from the dropdown menu if you have multiple domains
  5. Specify the Document Root (home directory) for your subdomain
  6. Click the Create button

The system automatically creates the necessary DNS records and directory structure for your new subdomain.

Document Root Configuration

The Document Root defines where your subdomain's files will be stored on the server. This path is relative to your account's home directory.

For example, if you create a subdomain called "store" and your account home directory is /home/username, the default document root might be /home/username/store.example.com/. You can customize this path during creation.

Key points about document roots:

  • The system auto-populates the Document Root field with a suggested path
  • You can modify this path to any valid directory location
  • The house icon in cPanel represents your account's home directory
  • Each subdomain should have its own unique directory
  • You cannot use your account's root home directory as a document root

Subdomain Management Best Practices

Keep these best practices in mind when working with subdomains:

Avoid wildcard subdomains: Wildcard subdomains (*.example.com) can interfere with service subdomains used by cPanel for webmail, cPanel access, and other services. Only use wildcard subdomains when absolutely necessary.

Organize your directories: Use clear, descriptive names for subdomain directories to make management easier. For example, use /public_html/blog for blog.example.com rather than generic names.

SSL certificates: If your main domain has an SSL certificate, you may need to add subdomain coverage or obtain separate certificates for subdomains to enable HTTPS.

Monitor resource usage: Each subdomain can run its own applications and consume server resources. Keep track of total resource usage across all subdomains.

Subdomain vs Addon Domain

Many users confuse subdomains with addon domains. Here's the difference:

Subdomains are extensions of your main domain (blog.example.com). They share the same domain registration and typically the same hosting account resources.

Addon domains are completely separate domain names (differentsite.com) that you host on the same account. They appear as independent websites with different domain registrations.

Use subdomains when you want to organize sections of the same website or brand. Use addon domains when hosting multiple unrelated websites on one hosting account.

Troubleshooting Common Subdomain Issues

Subdomain not accessible: Wait 24-48 hours for DNS propagation. Clear your browser cache and try accessing from a different device or network.

404 errors: Verify that files exist in the correct document root directory. Check file permissions (typically 644 for files, 755 for directories).

Subdomain shows main site content: This usually indicates incorrect document root configuration. Edit the subdomain settings to point to the correct directory.

Cannot create subdomain: You may have reached your account's subdomain limit. Check your hosting plan specifications or contact support.

Frequently Asked Questions

How many subdomains can I create?

The number of subdomains you can create depends on your hosting plan. Most OBHost plans offer unlimited subdomains, but check your specific plan details. You can create as many as you need for organizing your website content and services.

Do subdomains affect my main website's SEO?

Search engines treat subdomains as separate entities from your main domain. This means subdomain content doesn't directly boost your main domain's rankings, but it also won't hurt them. Subdomains can rank independently in search results for their own content.

Can I password protect a subdomain?

Yes, you can password protect any subdomain using cPanel's Directory Privacy feature. This allows you to restrict access to specific subdomains while keeping your main site public, which is useful for staging sites, member areas, or internal resources.

How do I delete a subdomain?

To remove a subdomain, go to the Subdomains interface in cPanel, find the subdomain in the list, and click the Remove or Delete option. Note that this removes the DNS records but does not automatically delete the subdomain's files from your server. You'll need to manually delete the directory if you want to free up disk space.

Our support team is available 24/7 to help with subdomain configuration, DNS issues, or any other hosting questions. Visit our contact page or email support@obhost.org for assistance.


Was this answer helpful?

« Back