Ahosting Logo
Knowledge Base

How to Set Up a Subdomain with DNS

Subdomains are prefixes to your main domain (like blog.example.com). They can point to the same server, different servers, or third-party services.

Creating a Subdomain

There are two steps:

  1. Add DNS record for the subdomain
  2. Configure hosting to serve content (if hosting locally)

Method 1: Subdomain on Same Server

If hosting the subdomain on Ahosting:

  1. Go to cPanel > Domains
  2. Click Create A New Domain
  3. Enter full subdomain: blog.example.com
  4. Click Submit

cPanel automatically creates the DNS record and folder.

Method 2: Subdomain to Different IP

If pointing to a different server:

  1. Go to Zone Editor
  2. Click + A Record
  3. Name: blog (the subdomain prefix)
  4. Address: The destination IP address
  5. Click Add Record

Method 3: Subdomain to External Service

If pointing to a third-party service (Shopify, Tumblr, etc.):

  1. Go to Zone Editor
  2. Click + CNAME Record
  3. Name: shop (the subdomain prefix)
  4. Record: shops.myshopify.com (service hostname)
  5. Click Add Record

Common Subdomain Configurations

Subdomain Record Type Points To
www A or CNAME Same server or example.com
blog A Same server IP
shop CNAME shops.myshopify.com
mail A Mail server IP
staging A Development server IP
app A Application server IP

Wildcard Subdomain

A wildcard record handles all undefined subdomains:

*.example.com    A    192.168.1.1

Any subdomain not specifically defined will use this record.

SSL for Subdomains

Each subdomain needs its own SSL certificate or a wildcard certificate.

  • AutoSSL: Automatically covers subdomains added in cPanel
  • Wildcard SSL: Covers *.example.com with one certificate
  • External services: Usually provide their own SSL

Subdomain Email

You can create email addresses for subdomains:

MX records can be added for subdomains if needed.

Testing Subdomain Setup

  1. Wait for DNS propagation (few minutes to hours)
  2. Use nslookup or dig to verify record:
    nslookup blog.example.com
  3. Try accessing in browser

Troubleshooting

Subdomain not resolving

  • Check DNS record exists in Zone Editor
  • Wait for propagation
  • Verify no typos in subdomain name

Subdomain shows wrong content

  • Verify document root is correct in cPanel
  • Check A record points to correct IP
  • Clear browser cache

SSL not working on subdomain

  • Run AutoSSL from cPanel
  • Wait for certificate issuance
  • Check subdomain is added in cPanel Domains