www and non-www Both Open Separately

Visitors can reach both yourdomain.com and www.yourdomain.com. Both load. Why this hurts SEO and how to fix.

You type https://yourdomain.com — site loads. Type https://www.yourdomain.com — site loads, identical content. Both return 200. To you it looks fine; to Google’s deduplication and to anyone tracking backlinks, you have two sites with identical content, splitting link equity and creating canonical confusion. The fix is straightforward: pick one as canonical, 301 the other to it, at the platform level (not just in HTML canonical tags). This is similar to www vs root redirect but specifically about when both versions already exist and load — the harder cleanup case.

Common causes

Ordered by hit rate, highest first.

1. Both versions added to the host without redirect

You added both yourdomain.com and www.yourdomain.com as separate domains on Vercel/Netlify. The host serves both happily but doesn’t set up a redirect by default.

How to spot it: Platform dashboard → Domains → both are “primary” or both are configured. Should be one primary, one redirect.

2. CDN proxies both directly to origin

If Cloudflare or another CDN has both records as proxied A/CNAME, both reach origin and serve content. CDN doesn’t redirect unless you tell it to.

How to spot it:

curl -sI https://yourdomain.com | head -3
curl -sI https://www.yourdomain.com | head -3

Both return 200 = both serve content directly.

3. Hosting platform doesn’t auto-redirect across bindings

Some platforms support adding both but require manual redirect config. They don’t infer “you probably want one as primary.”

How to spot it: Platform docs may say “add both and set one as primary” — if you skipped the “set primary” step, no redirect.

4. Canonical tag set but no HTTP redirect

You added <link rel="canonical" href="https://yourdomain.com/..."> on all pages. Tag works for Google but visitors still see the URL they typed. Direct backlinks may still point to the non-canonical.

How to spot it: Both URLs load with 200 (not 301). Canonical tag alone doesn’t redirect.

5. Old setup with manual nginx serving both

Self-hosted or older shared hosting may have nginx serving both with server_name yourdomain.com www.yourdomain.com; and no redirect rule. Both work but you have a duplicate-content problem.

How to spot it: SSH into server, look at nginx config. If server_name lists both without a separate redirect server block, that’s it.

Shortest path to fix

Step 1: Pick canonical

Either works for SEO. Pick:

  • Apex (yourdomain.com) if you want shorter URLs and your DNS provider supports ALIAS/ANAME.
  • www (www.yourdomain.com) if you want easier CNAME handling for CDNs.

Once chosen, document and commit.

Step 2: Configure host

Vercel — Project → Settings → Domains:

  • Add both yourdomain.com and www.yourdomain.com
  • Click the non-canonical one → “Redirect to” → select the canonical
  • Vercel issues a 301 automatically

Netlify — Site settings → Domain management:

  • Add both
  • Click “primary” toggle on the canonical
  • Netlify auto-redirects the other

Firebasefirebase.json:

{
  "hosting": {
    "redirects": [
      { "source": "/(.*)", "destination": "https://yourdomain.com/:1", "type": 301 }
    ]
  }
}

(Configure on the non-canonical site if Firebase requires separate apps.)

Cloudflare — Rules → Redirects:

URL pattern: https://www.yourdomain.com/*
Forwarding URL: https://yourdomain.com/$1
Status: 301

Step 3: Verify

curl -sI https://www.yourdomain.com | head -5

Should return:

HTTP/2 301
Location: https://yourdomain.com/

If returns 200, redirect isn’t configured.

Step 4: Update HTML canonical tag

Make sure your template emits canonical pointing to the canonical version:

<link rel="canonical" href="https://yourdomain.com/your-article/" />

Not the alternative version.

Step 5: Update Search Console

If both versions had been verified separately, Search Console may have two properties. Keep both (still useful for monitoring) but treat the canonical as primary.

After redirect is live, the non-canonical property will gradually show fewer indexed URLs.

Step 6: Wait for Google consolidation

Over 2-4 weeks, Google consolidates link equity into the canonical. Search Console → Performance → Pages should show the non-canonical URLs decreasing.

When this is not on you

Some platforms have specific quirks (Firebase’s primary-site model, Cloudflare’s apex vs subdomain handling). If platform behavior doesn’t match docs, file support ticket with specifics.

Easy to misdiagnose as

Setting canonical link tag alone doesn’t prevent dual serving. The 301 at platform level is what consolidates Google’s understanding.

Prevention

  • Decide www vs apex on day one of any new domain.
  • Always set the redirect at platform/CDN level, not just canonical tag.
  • After any DNS or hosting change, re-verify with curl -sI that one version 301s to the other.
  • For team-managed domains, document the canonical choice in a DOMAIN.md file.

FAQ

  • Which is better, www or apex? No SEO difference. Pick one based on technical preferences.
  • Can I switch later? Yes, but it requires a 301 chain (old canonical → new canonical), canonical tag updates, and 4-8 weeks for Google to fully shift. Don’t switch casually.

Tags: #Domain #DNS #SSL #Troubleshooting #Redirect