Root Domain or www: How to Pick

Root vs www is cosmetic — until both serve the same content. Use this DNS table, redirect config, and curl verification to lock it down once.

In 2026 the www vs root-domain debate is almost entirely cosmetic — until you accidentally serve the same content on both, and now Google sees two sites with one URL of authority each. The decision is small. The execution must be precise — DNS, hosting, canonical tag, and Search Console all aligned.

Background

Historically www was a hostname convention pointing to the web server, while the root domain might point at email, FTP, or other services. Modern hosting collapses this — both can point at the same web service. What matters is picking one as canonical and making the other 301-redirect to it, so search engines, browsers, and copy-paste users converge.

How to tell

  • Both https://yoursite.com and https://www.yoursite.com load your site (no redirect between them).
  • Search Console shows two properties or split impressions for the same content.
  • Backlinks point at a mix of both versions.
  • You see canonical tag on one version pointing at the other.
  • dig +short returns IPs for both apex and www independently.

Quick verdict

Pick one — most modern indie sites pick the root (yoursite.com) because it is shorter and matches typing habits. Set up a 301 redirect from the other to the chosen one. Configure DNS, host, and canonical tags to all agree.

Before you start

  • Lower DNS TTL to 300s 24 hours before the change.
  • Choose canonical (apex or www) — write it down.
  • Know who runs your DNS (registrar vs Cloudflare).

Step by step

  1. Decide and write it down. Default to apex for new indie sites. Stay with www if you already have an established www site with backlinks.

  2. Add DNS records — both, ultimately resolving to the same place. Apex-primary on a typical host:

Type   Name        Value                            TTL
A      @           76.76.21.21      (host's anycast)  300
A      @           76.76.21.22                        300
CNAME  www         cname.vercel-dns.com.              300

Firebase-style:

Type   Name        Value                            TTL
A      @           199.36.158.100                    300
A      @           199.36.158.101                    300
CNAME  www         your-project.web.app.             300
  1. In your host, mark one as primary. Vercel: Project → Domains → mark yoursite.com as Primary, www.yoursite.com is auto-redirected with 301. Firebase: Hosting → Custom domains → set redirect direction.

  2. If your host does not auto-redirect (Cloudflare-fronted only), add a Page Rule or Redirect Rule:

# Cloudflare Bulk Redirects (CSV import)
source_url,target_url,status,preserve_query_string,preserve_path_suffix
https://www.yoursite.com/*,https://yoursite.com/$1,301,true,true

Or in Cloudflare’s Redirect Rules UI:

When incoming requests match
  Hostname equals  www.yoursite.com
Then
  Type:         Static
  URL redirect: https://yoursite.com${uri.path}${uri.query}
  Status code:  301
  Preserve query string: ON
  1. Set canonical tag on every page pointing at the chosen version. In an Astro layout:
<link rel="canonical" href={`https://yoursite.com${Astro.url.pathname}`} />

Verify after deploy:

grep -R 'rel="canonical"' dist | grep -v 'https://yoursite.com' | head
# any output is a leak to the non-canonical version
  1. In Search Console, add the chosen version as the property. Use Domain property (TXT) so both apex and www are covered, then make sure the URLs you submit in the sitemap are the canonical apex.

  2. Verify the redirect with curl:

curl -sI https://www.yoursite.com         | head -3
# HTTP/2 301
# location: https://yoursite.com/

curl -sI http://yoursite.com              | head -3
# HTTP/1.1 301 Moved Permanently
# Location: https://yoursite.com/

curl -sI https://yoursite.com             | head -3
# HTTP/2 200

The chain you want is at most one hop: http://wwwhttps://apex should not pass through http://apex or https://www. Single-hop is the goal.

  1. Update controllable backlinks (social bios, GitHub README, email signatures). 301s handle search-engine-visible inbound links; humans see the redirect blink.

Implementation checklist

  • DNS has records for both apex and www, ultimately to the same host.
  • Host’s “primary domain” matches your chosen canonical.
  • curl -sI shows 301 from non-canonical to canonical in one hop.
  • Canonical tag on every page references the chosen version.
  • Search Console Domain property + sitemap uses the canonical.

After-launch verification

  • dig +short A yoursite.com and dig +short A www.yoursite.com both resolve.
  • Lighthouse on both URLs — one gets 200, the other shows the redirect.
  • Search Console Performance page shows traffic only on the canonical version after 4 weeks.

Common pitfalls

  • Serving the same content on both root and www without a redirect — duplicate content in Google’s eyes.
  • Pointing root and www at different builds (one to staging, one to prod) — common when a redirect is misconfigured.
  • Choosing www then forgetting half your DNS provider docs assume root — leads to broken records.
  • Mismatched canonical tag — page is on root but tag says www, or vice versa. Inconsistency confuses crawlers.
  • Submitting one version to Search Console and using the other for canonical — pick one and use it everywhere.
  • A multi-hop redirect (http://wwwhttp://apexhttps://apex) that loses signal. Always one hop.

FAQ

  • Does Google care which one I pick?: No, as long as you pick one and 301 the other. Mixed signals are what hurts.
  • Is www outdated?: Stylistically, yes — most new sites drop it. Technically it is still completely fine and even has slight DNS flexibility advantages (CNAME at subdomain is universally supported).
  • Can I change later?: Yes, but treat it like a mini-domain migration — set up 301s, update Search Console, update canonical. Expect a small SEO blip during recovery.
  • What if my host only supports one?: Most modern hosts support both with auto-redirect. If yours does not, switch hosts or front it with Cloudflare to handle the redirect.
  • Should I CNAME the apex via Cloudflare CNAME flattening?: Yes, that is the standard way to use CNAME-like behavior on the apex when your host wants a CNAME but the registrar will not accept one at @.

Tags: #Indie dev #Domain #DNS #Canonical #SEO