A CNAME (Canonical Name) record creates an alias from one domain name to another. Instead of pointing to an IP address, it points to another hostname.
How CNAME Works
www.example.com. CNAME example.com.
When someone visits www.example.com:
- DNS looks up www.example.com
- Finds CNAME pointing to example.com
- Looks up A record for example.com
- Returns the IP address
Common CNAME Uses
| Subdomain | Points To | Purpose |
|---|---|---|
| www | example.com | www alias to root |
| blog | mysite.wordpress.com | External blog platform |
| shop | shops.myshopify.com | E-commerce platform |
| ghs.google.com | Google Workspace | |
| cdn | d1234.cloudfront.net | CDN distribution |
Adding a CNAME Record in cPanel
- Go to Zone Editor
- Click Manage for your domain
- Click + CNAME Record
- Enter:
- Name: The subdomain (e.g., www, blog, shop)
- Record: The target hostname (e.g., example.com)
- TTL: Time to live (default 14400)
- Click Add Record
CNAME Rules and Restrictions
- Cannot use CNAME for root domain: example.com cannot be a CNAME (use A record instead)
- Cannot coexist with other records: If blog.example.com has a CNAME, it cannot have A, MX, or TXT records
- Target must be a hostname: Not an IP address
- Include trailing dot: example.com. (in raw zone files)
CNAME vs A Record
| CNAME | A Record |
|---|---|
| Points to hostname | Points to IP address |
| Requires extra DNS lookup | Direct resolution |
| Easier maintenance | Slightly faster |
| Cannot be used for root | Can be used anywhere |
CNAME Flattening (ALIAS/ANAME)
Some DNS providers offer ALIAS or ANAME records that work like CNAME but for root domains. cPanel does not support this - use A record for root domain instead.
Examples with Third-Party Services
Shopify Custom Domain
www CNAME shops.myshopify.com
GitHub Pages
www CNAME username.github.io
Cloudflare
cdn CNAME example.com.cdn.cloudflare.net
Troubleshooting CNAME
- Site not loading: Verify target hostname is correct
- SSL errors: Target must support SSL for your domain
- Propagation: Wait up to 48 hours for changes
Check CNAME record
nslookup -type=CNAME www.example.com dig www.example.com CNAME