Pre-requirements
- Administrator access to your cPanel account.
- Basic knowledge of DNS records (A and NS records).
- Access to your domain registrar’s or DNS provider’s control panel to edit DNS records.
Introduction
Many users encounter issues when trying to access their subdomains and addon domains. In some cases, subdomains are only reachable via the primary domain, which is not ideal. This article explains the difference between subdomains and addon domains and provides a step-by-step guide to resolving access issues by properly configuring them in cPanel and ensuring DNS records are set correctly.
Issue
If you can only access your subdomains via the primary domain (e.g., www.example_domain.com/2ndexample_domain.com instead of example_nddomain.com directly), you may have incorrect configurations for subdomains and addon domains.
Cause: Confusing Subdomains and Addon Domains
Before addressing the issue, let’s clarify the difference between subdomains and addon domains:
What is an Addon Domain?
An addon domain links a new domain to a directory in your web hosting account. It allows you to host multiple websites under the same hosting account. For example, if you add addon.com as an addon domain, you can access it in any of the following ways:
- addon.com
- addon.example.com
- example.com/addon
What is a Subdomain?
A subdomain is a subsection of your website that often exists as a sub-directory of your main domain's root directory. It uses a prefix (e.g., blog) in conjunction with your main domain (e.g., blog.example.com).
Subdomains are typically used to separate different parts of a website, like shop.example.com for an online store.
However, to access subdomains or addon domains directly (e.g., $2nddomain.com), the necessary DNS records must be in place.
Solution: Correcting Subdomain and Addon Domain Configuration in cPanel
To resolve this issue, you need to ensure that the domain configurations are correct, and the DNS records are properly set up. Below are the steps to achieve this.
Step 1: Check DNS Records
To ensure that your subdomains and addon domains are reachable directly, you need to verify that the correct DNS records (A and NS) are in place. If DNS records are missing or incorrectly configured, your domains won’t resolve properly.
Linux Command to Check DNS Records (Optional)
# Check A record for $2nddomain.com
dig A $2nddomain.com
# Check NS record for $2nddomain.com
dig NS $2nddomain.com
If you are using external DNS (outside of cPanel), make sure to log into your DNS provider's control panel and add the necessary records there.
Step 2: Correctly Add Subdomains or Addon Domains in cPanel
Option 1: Adding $2nddomain.com as an Addon Domain
- Log into your cPanel dashboard.
- Navigate to Domains > Addon Domains.
- Enter $2nddomain.com as the new domain.
- Specify the directory where the domain’s files will be stored (you can create a new directory or use an existing one).
- Click Add Domain to complete the process.
Option 2: Creating a Subdomain in cPanel
- Log into your cPanel dashboard.
- Go to Domains > Subdomains.
- Enter the desired subdomain name (e.g., blog) followed by the domain (e.g., example.com) to create blog.example.com.
- Specify the directory where the subdomain’s files will be stored.
- Click Create to finalize the subdomain creation.
Step 3: Verify DNS Records for Subdomains or Addon Domains
After configuring your subdomain or addon domain, verify that the DNS records have propagated properly. You can use the following commands or online DNS tools:
Linux Command to Verify A Record for Subdomains or Addon Domains
# Check A record for $2nddomain.com
dig A $2nddomain.com
# Check A record for subdomain.example.com
dig A subdomain.example.com
Ensure the DNS records resolve to the correct IP address of your hosting server. If not, update the records in your DNS provider’s control panel.
Step 4: Redirect Subdomains or Addon Domains (Optional)
If you want to redirect a subdomain or addon domain to a different URL, you can set up a redirect in cPanel:
- Log into cPanel.
- Go to Domains > Redirects.
- Select the domain or subdomain you wish to redirect and enter the destination URL.
- Click Add Redirect to complete the process.
Gotchas to Avoid
- Incorrect DNS Records: Ensure both A and NS records are correctly set for subdomains and addon domains.
- Propagation Delays: DNS changes may take up to 48 hours to propagate globally. Be patient and verify DNS records after this period.
- Confusing Subdomains and Addon Domains: Understand the difference between subdomains and addon domains to configure them properly in cPanel.
By following these steps, you can resolve issues with accessing subdomains and addon domains directly, ensuring they are properly configured in cPanel and have the correct DNS records. Whether you're creating new subdomains or addon domains, or simply correcting DNS issues, these steps will help you avoid common pitfalls.
For more detailed guidance on domain and DNS management, visit our Knowledge Base.