Find cheap domain names for your website - namesilo.com
Namesilo Blog
Blog
DNS12 min

Root Domain Options: CNAME Flattening vs. HTTP Redirects (Pros & Cons)

NS
NameSilo Staff

10/9/2025
Share
The technical limitation preventing CNAME records at root domains has frustrated web administrators for years. You want example.com to point to your content delivery network or load balancer, but DNS specifications forbid CNAME records at the apex. This constraint has spawned multiple workarounds, each with distinct trade-offs affecting performance, search optimization, and architecture.

The Root Domain CNAME Problem

DNS standards prohibit CNAME records at the zone apex (the root domain without any subdomain prefix). The restriction exists because CNAME records must be the only record of any type at a given name. Root domains require other records, SOA records for zone authority, NS records for nameserver delegation, and often MX records for email, making CNAME incompatible at the apex.
This becomes problematic when your hosting infrastructure uses dynamic IP addresses or load balancers that you'd normally reference with a CNAME. You can point www.example.com to loadbalancer.hosting.com using a CNAME without issue, but example.com (the bare domain) requires an A record with a specific IP address.
Static IP addresses work, but they create operational friction. When your hosting provider changes infrastructure or you migrate to a new platform, updating A records across every domain becomes necessary. CNAME records would have automatically followed the hosting provider's changes.

CNAME Flattening and ALIAS Records: Dynamic Resolution

CNAME flattening and ALIAS records solve the apex CNAME problem by performing resolution at the authoritative nameserver level. Instead of returning a CNAME record that tells resolvers to look elsewhere, these approaches return A records that the nameserver obtained by resolving the target hostname dynamically.

How CNAME Flattening Works

When a DNS query arrives for your root domain, your nameserver internally resolves the CNAME target (like loadbalancer.hosting.com) to get its current IP addresses, then returns those IPs as A records in the response. To the querying resolver, it looks like your domain has normal A records, but those records are dynamically generated based on the CNAME target's current resolution.
ALIAS records (sometimes called ANAME records) provide similar functionality with slightly different semantics. The nameserver stores a pointer to the target hostname and resolves it on demand to provide current IP addresses.

Performance Characteristics

CNAME flattening introduces latency into DNS resolution. Your authoritative nameserver must perform an additional lookup to resolve the target before answering queries. This adds milliseconds to response times compared to serving static A records from cache.
The impact varies based on implementation. Some DNS providers cache the flattened results and refresh them periodically in the background, minimizing query-time latency. Others resolve on every query, making responses slower but ensuring maximum freshness.
Geographic distribution also affects performance. If your nameserver must query a distant target to flatten the CNAME, latency increases. Well-architected systems place nameservers near the targets they flatten to minimize resolution delay.

Freshness and TTL Considerations

When infrastructure behind a flattened CNAME changes, load balancer IPs rotate, servers are added or removed, there's a delay before the changes propagate through the flattening layer. Your nameserver might continue returning stale IPs for minutes after the target changes, depending on caching behavior.
This staleness window creates potential availability issues. If a load balancer IP becomes invalid but your flattened records still point to it, visitors get connection failures until the records refresh. The longer your DNS provider caches flattened results, the longer this window persists.

Provider Lock-In

CNAME flattening isn't a DNS standard, it's a proprietary feature offered by specific DNS providers. Once you rely on it, migrating to a different DNS provider that doesn't support flattening requires architectural changes. You can't simply transfer your zones unchanged.
This lock-in matters more for some organizations than others. If you rarely change DNS providers and your current provider's flattening implementation works reliably, the limitation may be acceptable. Organizations prioritizing portability prefer standards-based approaches.

HTTP Redirects: Canonical Domain Selection

The alternative to apex resolution involves picking one canonical domain (either www.example.com or example.com) and redirecting all traffic from the other variant to your chosen canonical form. This approach leverages standard DNS and HTTP rather than DNS extensions.

Architectural Simplicity

With HTTP redirects, DNS configuration remains straightforward. If you choose www.example.com as canonical, your root domain gets an A record pointing to a simple web server that issues HTTP redirects. That server doesn't need to host your actual site, it only needs to redirect browsers to www.
example.com.     A    203.0.113.10
www.example.com. CNAME loadbalancer.hosting.com.
The redirect server at 203.0.113.10 returns 301 (permanent redirect) responses for all requests, sending traffic to www.example.com. Your actual infrastructure lives entirely at www, where you can use a CNAME without restriction.
Alternatively, if you prefer the root domain as canonical, the pattern reverses:
example.com.     A    loadbalancer.hosting.com. (resolved to IPs)
www.example.com. CNAME redirect.example.com.
Here www redirects to the root domain, and you accept the limitation of needing A records at the apex.

SEO Implications

Search engines treat www and non-www variants as potentially different sites. Running content at both without redirects can split your ranking authority between them, weakening both. Choosing one canonical form and redirecting the other consolidates your search presence.
301 permanent redirects preserve search ranking when moving from one URL to another. Engines recognize that you've intentionally unified the variants rather than fragmenting your content. This consolidation takes time, weeks or months for search indexes to fully adjust, but ultimately strengthens your domain's authority.
Consistency matters more than which variant you choose. Picking www or root as canonical doesn't significantly impact SEO, but waffling between them or failing to redirect creates confusion. Search engines and visitors alike benefit from a clear, consistent canonical domain.

Link Equity and Backlinks

Over time, your website accumulates inbound links from other sites, social media, and various online sources. Some people link to www.example.com while others use example.com. These backlinks represent accumulated trust and authority.
Redirecting one variant to the other ensures all accumulated link equity flows to your canonical domain. Without redirects, you're effectively splitting that equity between two destinations. The redirect consolidates everything to your chosen canonical form.
This consolidation particularly matters when registering domains for new projects. From launch day, decide on your canonical form and implement redirects immediately so links accumulate on the canonical variant from the beginning.

Cookie Scope and Security Considerations

Cookies set at the root domain (example.com) are sent to all subdomains: www.example.com, api.example.com, blog.example.com. Cookies set at www.example.com only go to that specific subdomain.
This scoping affects performance and security. If your root domain sets large cookies, every request to every subdomain carries that cookie data. API requests, image loads, and every other HTTP request includes the cookie overhead.
Security-conscious applications often isolate cookie-heavy services to subdomains to limit cookie exposure. Authentication cookies set on www.example.com don't automatically travel to api.example.com, reducing attack surface if the API has vulnerabilities.

Root Domain as Canonical

When you make example.com canonical, cookies set there reach all subdomains. This simplifies single sign-on across subdomains, one authentication cookie works everywhere. However, it also means every subdomain inherits the root's cookie payload.
If you run static assets on a subdomain (static.example.com) to improve load times, root domain cookies defeat the optimization. The browser sends cookies with every asset request, negating bandwidth savings.

WWW as Canonical

Making www.example.com canonical isolates cookies to that subdomain by default. Other subdomains remain cookie-free unless you explicitly set cookies for them. This gives you granular control over cookie scope.
You can still implement single sign-on by explicitly setting cookies at the root domain level (domain=example.com) when needed, but it's an intentional decision rather than the default behavior.

Cookie Security Headers

Modern security practices use cookie attributes like Secure, HttpOnly, and SameSite to limit cookie exposure. The domain scope (root vs. subdomain) adds another layer to this security posture.
Applications handling sensitive data often prefer subdomain isolation to limit cookie reach. If your www site gets compromised, attacker-readable cookies aren't automatically exposed to your API or admin interfaces on other subdomains.

TLS Certificate Considerations

TLS certificates protect both your root and www variants, but the configuration affects user experience and security warnings.

Certificate Coverage

Most organizations obtain certificates covering both example.com and www.example.com, either through a multi-domain certificate or a wildcard certificate. This ensures visitors reach encrypted versions regardless of which variant they type.
With proper certificates in place, the choice between root and www canonicalization doesn't directly affect TLS. However, the redirect infrastructure needs certificates too. If example.com redirects to www.example.com, the redirect server must have a valid certificate for example.com or visitors see security warnings before the redirect happens.

HSTS and Preloading

HTTP Strict Transport Security (HSTS) tells browsers to only access your site over HTTPS, preventing protocol downgrade attacks. HSTS headers can specify includeSubDomains, which applies the policy to all subdomains.
If your root domain is canonical and you enable HSTS with includeSubDomains, every subdomain must support HTTPS. This creates operational constraints, you can't run any subdomain without TLS, even temporarily for testing.
HSTS preload lists take this further by hardcoding HTTPS requirements for your domain into browsers themselves. Preload requires root domain canonicalization with includeSubDomains, making www-as-canonical incompatible with preloading.
This incompatibility matters only if you want preload list inclusion for maximum security. Most sites function perfectly well with standard HSTS policies without preloading.

Performance Trade-offs

Initial Page Load

With CNAME flattening, visitors reach your site directly regardless of whether they type the root or www variant. No redirect hop occurs, saving one round trip on the initial page load.
With HTTP redirects, visitors typing the non-canonical variant experience an additional HTTP round trip before reaching your content. For example.com redirecting to www.example.com:
  1. Browser requests example.com
  1. Redirect server returns 301 to www.example.com
  1. Browser requests www.example.com
  1. Your site loads
This adds latency, typically 50-200 milliseconds depending on geographic distance and network conditions. For performance-critical applications, this delay matters.

DNS Resolution Time

CNAME flattening moves complexity into DNS resolution. Instead of a simple A record lookup returning cached IPs, your nameserver must resolve the target hostname, adding milliseconds to DNS queries.
With HTTP redirects using standard A records, DNS resolution is straightforward and fast. The latency appears in HTTP layer redirects instead.
Where the latency lives matters for optimization. DNS resolution typically happens once per domain, with results cached by the resolver. HTTP redirects happen on every visit when users type or bookmark the non-canonical variant.

CDN Integration

Content delivery networks often prefer CNAME records for integrating their infrastructure with your domain. You point www.example.com at their load balancer hostname, and they dynamically route traffic to optimal edge locations.
For the root domain, CDN providers either require your DNS provider supports CNAME flattening or provide you with specific IP addresses for A records (usually anycast IPs that work globally). Some CDNs operate their own DNS services with flattening built in, solving the problem by controlling both layers.
When selecting hosting infrastructure, consider how your provider handles root domain integration with their platform. Solutions that require CNAME flattening lock you into DNS providers supporting that feature.

Email Delivery and MX Records

Root domain configuration affects email through MX record placement and SPF policy setup.

MX Record Requirements

MX records must exist at the domain where you receive email. If you receive mail at @example.com addresses, you need MX records at example.com. These MX records coexist happily with A records but would conflict with CNAME records if CNAMEs were allowed at the root.
CNAME flattening and ALIAS records don't interfere with MX records since they're implemented at the nameserver rather than as actual CNAME records in the zone. Your DNS zone still contains normal A and MX records from a structural perspective.

SPF Record Placement

SPF records (implemented as TXT records) specify which servers can send email for your domain. These also live at the root domain and coexist with A records or flattened CNAMEs without conflict.
The canonicalization choice (www vs. root) doesn't directly affect email since email always uses the root domain regardless of web canonicalization. Whether your website prefers www or not, email remains @example.com.
However, if you're managing email services alongside your website, be mindful that DNS configuration changes affecting the root domain could inadvertently impact email if not carefully reviewed.

Making the Decision

Several factors guide the choice between CNAME flattening and HTTP redirects:
Choose CNAME flattening when:
  • Performance is critical and redirect latency is unacceptable
  • Your hosting infrastructure uses dynamic IPs that change frequently
  • You prefer the root domain as canonical and want direct access without redirects
  • Your DNS provider offers reliable flattening with good performance
  • Lock-in to a specific DNS provider is acceptable
Choose HTTP redirects when:
  • You want maximum portability across DNS providers
  • Your architecture already points www at a CNAME target
  • You prefer explicit control over canonical selection
  • The additional redirect latency is acceptable for your use case
  • You want cookie isolation between root and www
Consider a hybrid approach:
  • Use www as canonical with standard CNAME
  • Implement root domain A records (possibly via flattening) for direct access
  • Redirect root to www, accepting the latency trade-off
  • This combines portability with accessibility at both variants

Migration Strategies

Changing canonical domains after launch requires careful handling to minimize SEO disruption and user confusion.

From Root to WWW

If you've been running at example.com and want to move to www.example.com:
  1. Ensure www infrastructure is ready and tested
  1. Implement 301 redirects from root to www
  1. Update internal links throughout your site to use www
  1. Submit updated sitemaps to search engines showing www URLs
  1. Monitor search rankings and traffic during the transition
  1. Update marketing materials and documentation to reference www
The transition period typically spans several months as search engines reindex your content. Don't panic if rankings fluctuate initially, this is normal during canonicalization changes.

From WWW to Root

Moving from www.example.com to example.com follows similar steps but requires ensuring your root domain can handle traffic reliably, either through static A records or CNAME flattening.
The technical challenges are slightly greater since you're moving from the CNAME-compatible www to the CNAME-restricted root. Ensure your infrastructure provides stable IPs or that your DNS provider supports flattening before initiating the migration.

Monitoring and Validation

Regardless of your approach, implement monitoring to catch issues:
For CNAME flattening:
  • Monitor DNS resolution latency from multiple geographic locations
  • Verify flattened IPs match your infrastructure's current state
  • Alert on resolution failures or stale data
  • Test failover behavior when target infrastructure changes
For HTTP redirects:
  • Monitor redirect response times
  • Ensure redirects use 301 (permanent) not 302 (temporary)
  • Verify redirect targets remain accessible
  • Check that redirect infrastructure has valid TLS certificates
  • Measure impact on page load times
For both approaches:
  • Monitor search engine indexing of your canonical domain
  • Track organic search traffic patterns for both variants
  • Ensure analytics consolidate traffic to your canonical domain
  • Verify that backlinks increasingly target your canonical form

Emerging Standards and Future Considerations

DNS standards continue evolving. HTTPS DNS records (type 65) aim to provide integrated HTTPS metadata, potentially affecting how apex domains handle modern web requirements. Other proposals address apex CNAME limitations through standardized approaches.
Stay informed about DNS evolution, but don't wait for perfect standards before launching your site. Current approaches, whether flattening or redirects, work reliably for millions of websites. Choose the approach that fits your current needs, knowing you can migrate later if better options emerge.

Practical Recommendations

For most websites launching today, we recommend:
Small to medium sites: Use www as canonical with standard CNAME pointing to your hosting provider. Redirect root to www with simple A records pointing to redirect infrastructure. This provides maximum portability and simplicity.
Large, performance-critical sites: Consider CNAME flattening if your DNS provider offers reliable implementation. The performance benefit of eliminating redirect hops matters more at scale. Accept the provider lock-in as a reasonable trade-off.
Security-focused applications: Evaluate cookie scope implications carefully. If subdomain isolation provides security value, favor www as canonical. If you need HSTS preloading, root canonicalization becomes necessary.
Content delivery network users: Follow your CDN provider's recommendations, as they've optimized integration patterns for their infrastructure. Most CDNs work well with either approach but may have preferences.
Whatever you choose, implement it consistently from launch. Changing canonical domains later is possible but creates unnecessary complexity. Think through the implications, make a decision, and execute it cleanly from the start.
The perfect solution doesn't exist, every approach involves trade-offs. Understanding those trade-offs lets you make informed decisions aligned with your priorities, whether that's performance, portability, security, or simplicity.
ns
NameSilo StaffThe NameSilo staff of writers worked together on this post. It was a combination of efforts from our passionate writers that produce content to educate and provide insights for all our readers.
More articleswritten by NameSilo
Jump to
Smiling person asking you to sign up for newsletter
Namesilo Blog
Crafted with Care by Professionals

Millions of customers rely on our domains and web hosting to get their ideas online. We know what we do and like to share them with you.

This newsletter may contain advertising, deals, or affiliate links. Subscribing to a newsletter indicates your consent to our Terms of Use and Privacy Policy. You may unsubscribe from the newsletters at any time.