Why use CNAME flattening for apex domains

CNAME flattening was popularized in part by Cloudflare. We have used CNAME flattening successfully with multiple web-hosting providers. For the layperson, DNS A records are a pre-WWW artifact necessary to resolve the apex domain example.com from www.example.com or radar.example.com. You may see some old 2014 blog posts initially complaining about the idea of CNAME flattening, citing some initial hiccups that have long since been resolved.

Implement CNAME flattening

To enable CNAME flattening with your DNS records, first screenshot or otherwise backup your DNS settings. Don’t do this experiment during busy times, better to use on a little-used or test website first to ensure it works correctly with your complete setup.

  1. Determine the web address your web hosting provider puts your website at. E.g. for GitHub Pages it would be username.github.io
  2. Remove DNS A record for example.com that points to a specific IP address
  3. Add a CNAME record pointing example.com to the server address from step #1

For GitHub username joe with GitHub Pages site at joe.github.io, with desired web address example.com: make a CNAME DNS record with example.com as an alias to joe.github.io.


Cloudflare CNAME flattening article

Tags: , ,


Written by Michael Hirsch, Ph.D. //