How to set up a subdomain in cPanel (and what they're used for)
7 min read · 15-Jul-2025
villagehosting.in team
15 July 2025
A subdomain is a separate section of your website hosted under your main domain — like blog.yourdomain.com or shop.yourdomain.com. cPanel makes them easy to create. Here is how to use them effectively.
Subdomains are separate from subdirectories
blog.yourdomain.com (subdomain) and yourdomain.com/blog (subdirectory) are different architecturally. Subdomains get their own document root folder and can run different software. Subdirectories share the parent site's document root. For SEO, subdirectories generally inherit more domain authority. For separate applications, subdomains are cleaner. Choose based on your use case, not just ease of setup.
What subdomains are used for
Staging environment: staging.yourdomain.com — test changes before pushing to live
Blog or help centre: blog.yourdomain.com — separate WordPress installation or static site
E-commerce store: shop.yourdomain.com — separate WooCommerce or Shopify (custom domain)
Web application: app.yourdomain.com — your SaaS product on a different tech stack
API: api.yourdomain.com — your REST API, pointed to a VPS or different server
Regional versions: mumbai.yourdomain.com, delhi.yourdomain.com
Creating a subdomain in cPanel
- cPanel → Domains → Subdomains (or just Domains → Create A New Domain)
- Enter the subdomain (e.g.
blog) — the domain part (yourdomain.com) is pre-filled - The Document Root will auto-fill as
public_html/blog— this is where you upload files for this subdomain - Click Create
cPanel automatically creates the DNS record (A or CNAME) pointing to your server.
Setting a custom document root
Instead of public_html/blog, you can point the subdomain to any directory:
~/staging— for a complete staging site in its own folder~/myapp/public— for a Laravel application's public directory~/blog-wordpress— for a separate WordPress installation
Change the Document Root field when creating the subdomain to your preferred path.
Installing WordPress on a subdomain
After creating the subdomain:
- cPanel → WordPress (via Softaculous or similar)
- Install → choose your subdomain from the domain dropdown
- Set the Installation URL to the subdomain (e.g.
blog.yourdomain.com) - Complete the installation
This creates a completely separate WordPress installation, with its own database and files.
Pointing a subdomain to a different server
If your API or app lives on a VPS while your main site is on shared hosting:
- cPanel → Zone Editor → your domain
- Find the subdomain's A record that cPanel created
- Change the IP to your VPS's IP address
Or if you want a CNAME (e.g. pointing to a Heroku or Vercel deployment):
- Delete the A record cPanel created for the subdomain
- Add a CNAME record:
api.yourdomain.com → your-app.vercel.app
SSL for subdomains
After creating a subdomain, you need an SSL certificate for it:
Easiest method — Let's Encrypt in cPanel:
- cPanel → SSL/TLS Status
- Find your subdomain in the list
- Click "Run AutoSSL" — cPanel will issue a free Let's Encrypt certificate
Wildcard SSL (covers all subdomains):
A wildcard certificate *.yourdomain.com covers any subdomain. On cPanel:
- cPanel → SSL/TLS → Let's Encrypt SSL
- Select wildcard option — requires DNS validation
If using Cloudflare, their edge certificate covers all subdomains automatically (including wildcards on the free plan).
Setting up a subdomain redirect
To redirect www.yourdomain.com → yourdomain.com (or vice versa):
cPanel → Redirects:
- Type: Permanent (301)
- Redirect to:
https://yourdomain.com
For more control, add to .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.yourdomain\.com$ [NC]
RewriteRule ^(.*)$ https://yourdomain.com/$1 [R=301,L]
Wildcard subdomains
For WordPress Multisite (subdomain mode) or applications that need *.yourdomain.com to resolve:
cPanel → Zone Editor → your domain → Add Record:
- Type: A
- Name:
* - TTL: 14400
- Record: your server's IP address
This makes any subdomain resolve to your server. Your application then handles routing based on the subdomain name.
Removing a subdomain
cPanel → Domains → Subdomains → find the subdomain → Remove.
This removes the DNS record and cPanel entry, but does not delete the document root directory. Delete the files manually via File Manager if you do not need them.
Common subdomain issues
Subdomain shows "Welcome to cPanel" or index page: The document root is empty or has no index file. Upload your files to the subdomain's document root.
SSL warning on subdomain: Run AutoSSL from cPanel → SSL/TLS Status, or check if your wildcard certificate covers the subdomain.
Subdomain not resolving externally: DNS propagation takes up to 30 minutes after creation. Check with nslookup subdomain.yourdomain.com 8.8.8.8.
Subdomain shows main site: The document root is set to the same directory as the main domain. Check cPanel → Domains → Subdomains and verify the document root is different.