Question: What is a CNAME record and when should I use it? Print

  • shared hosting guide, GHFS web hosting, best hosting provider, SSD web hosting, VPS hosting setup, GHFS cloud hosting, GHFS Hosting, how to register a domain, hosting knowledge base, DNS configuration guide, domain and hosting tutorials, managed hosting services, how to transfer a domain, hosting control panel tutorial, email hosting setup, SSL installation guide, DNS records explained, MX record setup, A record guide, CNAME configuration, SSL certificate troubleshooting, WordPress installation GHFS, WordPress migration guide, optimize WordPress performance, fix internal server error, secure VPS server, enable SSH access, FTP upload guide, firewall configuration VPS, MySQL database tutorial, malware removal guide, disable root login SSH, secure hosting best practices, DDoS protection GHFS, Linux server commands, website security tutorial, PHP configuration guide, VPS hosting tutorial, cloud server configuration, Nginx setup GHFS, how to manage Linux VPS, Apache configuration guide, install Docker on VPS, Redis installation, Python hosting tutorial, hosting troubleshooting guide, MySQL optimization, hosting performance optimization, cPanel tutorial, Plesk tutorial, Node.js on VPS, secure website setup, SMTP configuration guide, email deliverability guide, SSL troubleshooting, server hardening tutorial
  • 0

Answer:

This article explains what a CNAME record is and when it should be used. A CNAME record points one domain name to another domain name.

1. What Is a CNAME Record?

A CNAME (Canonical Name) record makes one domain name an alias of another.
When a CNAME is created, the subdomain points to a different domain rather than an IP address.

Example:
www.yourdomain.com

→ yourdomain.com
cdn.yourdomain.com → mycdn.provider.com

A CNAME does not contain an IP address; it only redirects to another domain name.

2. When Should You Use a CNAME Record?

You should use a CNAME record in the following situations:

  • When you want the "www" version of your domain to point to your root domain
    www.yourdomain.com

  • → yourdomain.com

  • When using a CDN service
    cdn.yourdomain.com → cdn.provider.com

  • When connecting external services that require a subdomain
    mail.yourdomain.com → service.mailprovider.com

  • When directing subdomains to a central target

CNAME records are ideal for managing multiple subdomains that share the same endpoint.

3. When Should You Not Use a CNAME Record?

Avoid using CNAME records in these cases:

  • A CNAME cannot be used for the root domain (yourdomain.com).

  • You cannot have both a CNAME and an A record for the same hostname.

  • CNAME records cannot be used for MX or NS entries.

4. Example of Creating a CNAME Record

Name: www
Type: CNAME
Value: yourdomain.com

Another example:
Name: blog
Type: CNAME
Value: sites.customprovider.com

5. Advantages of Using a CNAME Record

  • Easy to maintain; if the target domain changes, the CNAME follows automatically.

  • Useful for pointing many subdomains to a single target.

  • Commonly used when integrating external services.

 


Was this answer helpful?

« Back