Skip to content

CNAME Record

A CNAME record maps one hostname to another hostname so the first can act as an alias for the second.

A CNAME, or Canonical Name, record maps one hostname to another hostname.

It allows one DNS name to act as an alias for another.

Cloudflare's DNS documentation defines CNAME records as records that map one domain name to another canonical domain name. Cloudflare DNS record types

Example

A common example is:

www.example.com → example.com

or:

shop.example.com → hosted-store.example-provider.com

The DNS resolver follows the target hostname to find the underlying destination.

CNAME vs. A Record

An A & AAAA Record points to an IP address.

A CNAME points to another hostname.

This distinction is useful when a service provider wants control over the underlying infrastructure.

For example, a SaaS provider may ask customers to create:

CNAME
portal.example.com → customer.platform.example

The platform can then change its internal addresses without asking the customer to update an IP address manually.

Why It Matters

CNAMEs are commonly used for:

  • www
  • SaaS applications
  • Hosted storefronts
  • Documentation sites
  • Verification
  • CDN configuration
  • External applications

Common Problems

Common problems include:

  • CNAME target typed incorrectly
  • Old service removed but DNS remains
  • Assuming a CNAME redirects the browser
  • Confusing DNS aliasing with an HTTP Redirect
  • Trying to place record combinations where DNS-provider rules do not allow them

CNAME vs. Redirect

A CNAME changes how a hostname resolves.

A Redirect tells a browser or client to request another URL.

The visitor may never see any change in the browser address bar when a CNAME is used.

They solve different problems.

How to Improve

Use a CNAME when the service specifically requires hostname aliasing.

Use an HTTP Redirect when the desired behaviour is:

Visitor requests this URL → browser moves to another URL.