A cname url redirect uses a Canonical Name (CNAME) record in DNS to map one domain name to another, enabling traffic to be directed to a different destination without changing the original URL. This method is often used to point subdomains or domains to external services like websites hosted on platforms such as Netlify, Cloudflare, or AWS.
CNAME records are part of the Domain Name System (DNS). They allow a domain or subdomain to act as an alias for another domain. For example, setting a CNAME record for blog.example.com to point to mysite.netlify.app helps requests to blog.example.com are resolved to the IP address associated with the Netlify site. The browser then loads the content from the target URL.
This differs from HTTP redirects (like 301 or 302 responses), which occur after DNS resolution and involve server-side instructions. A CNAME operates at the DNS layer, making it faster and more efficient for routing traffic to a new location. However, it cannot redirect to an IP address or a URL path-it must point to a fully qualified domain name.
DNS resolves domain names into IP addresses. When a user enters a URL, their device queries DNS servers to find the corresponding IP. A CNAME record tells the DNS system that one domain name is an alias for another. The resolver then follows the chain to the final IP address.
For example, if you set a CNAME record for shop.yourstore.com to point to store.shopify.com, the DNS lookup process goes:
This process happens in milliseconds. The user sees the content from Shopify's servers, but the URL remains shop.yourstore.com. This is useful for branding-keeping a consistent domain while hosting on a third-party platform.
CNAME url redirects are most effective when you want to maintain a branded domain while using a service provider. Here are typical scenarios:
| Type | Use Case | Example |
|---|---|---|
| Subdomain forwarding | Pointing a subdomain to a hosted site | blog.yoursite.com → yourblog.netlify.app |
| CDN integration | Using a content delivery network | assets.yoursite.com → yoursite.cdn.cloudflare.net |
| Third-party hosting | Hosting a site on Shopify, WordPress.com, etc. | shop.yoursite.com → yourshop.myshopify.com |
These setups are standard in web development. According to Cloudflare's documentation, CNAME records are recommended for directing traffic to their proxy services when using custom domains.
One non-obvious limitation: CNAME records cannot coexist with other DNS records (like A records or MX) on the same hostname. If you try to set both a CNAME and an A record for the same subdomain, the DNS system may reject the configuration or cause unpredictable behavior. This rule applies even within the same zone file.
CNAME url redirect is often mistaken for HTTP redirects, but they operate at different layers. A CNAME is a DNS-level alias. An HTTP redirect (e.g., 301 Moved Permanently) is a server response sent after the DNS lookup completes.
For example, if you set a CNAME for www.yoursite.com to point to example.com, the browser still shows www.yoursite.com in the address bar. But if you configure a 301 redirect on the server, the browser changes the URL to example.com and displays it in the address bar.
Another confusion arises between CNAME and A records. An A record maps a domain directly to an IP address. A CNAME maps a domain to another domain name. You can't use a CNAME for the root domain (e.g., yoursite.com) because it conflicts with the existence of an A record or TXT record needed for email and security verification.
As noted by Google's documentation on domain setup, "CNAME records should not be used for the apex domain (e.g., example.com) due to DNS limitations." Instead, Google recommends using ALIAS or ANAME records via a DNS provider that supports them.
Suppose you own blog.example.com and want to host your blog on Netlify. You create a site at myblog.netlify.app and want visitors to see the content under your domain.
Step 1: Log into your DNS provider (e.g., GoDaddy, Cloudflare).
Step 2: Create a CNAME record:
Step 3: Wait 5-10 minutes for propagation. Test with dig blog.example.com or online tools like MXToolbox.
Once propagated, accessing blog.example.com loads the Netlify-hosted site. The browser URL stays unchanged. This is a CNAME url redirect in action.
I've used this setup for personal projects. After configuring the CNAME, I verified the site loaded correctly using curl and browser dev tools. The request headers showed the correct origin, and the SSL certificate was valid-all without touching the application code.
Do not use CNAME records for the root domain (e.g., example.com). Most DNS providers do not allow CNAME records at the apex. This restriction exists because the root domain often requires multiple record types (A, TXT, MX, etc.), and DNS standards prohibit mixing CNAME with other records at the same level.
If you need to redirect example.com to another domain, use a redirect service like Cloudflare's Page Rules or a server-side redirect. Alternatively, use a CNAME for a subdomain (like www.example.com) and set up a redirect from the root domain via a web server or CDN.
Also avoid using CNAME records for load balancing or failover. While CNAMEs can point to load-balancer endpoints, they don't support health checks or automatic failover. For high-availability systems, use a DNS-based load balancer or a service like AWS Route 53 with weighted routing policies.
Understanding the distinctions prevents misconfiguration. Here's a comparison:
| Method | Layer | Can redirect to IP? | Can redirect to path? | Use Case |
|---|---|---|---|---|
| CNAME url redirect | DNS | No | No | Alias subdomains to other domains |
| HTTP 301/302 redirect | Application | Yes | Yes | Change URL permanently or temporarily |
| A record | DNS | Yes | No | Map domain to static IP |
For instance, if you're migrating a website from oldsite.com to newsite.com, a 301 redirect on the server is better than a CNAME because it preserves search engine rankings and informs users of the move. A CNAME only routes traffic-it doesn't signal intent.