What this setting does
Browsers happily serve example.com and www.example.com as two different hostnames. To search engines and AI crawlers, that's two copies of every page — which splits ranking signals and dilutes backlinks across both versions.
The Primary domain setting picks one host as canonical and 301-redirects the other to it. The redirect happens at the edge before the page renders, so crawlers always end up on the canonical host.
Where to configure it
- Go to Site Settings
- Under
CACHE & ROUTING, find Primary domain - Pick one of three options
The three options
example.com (apex) — www.example.com requests are 301-redirected to example.com. Choose this if you want shorter URLs and don't need to put the site on a CDN that requires a CNAME at the root (apex CNAME flattening is supported by Cloudflare and a few others, but not all DNS providers).
www.example.com — example.com requests are 301-redirected to www.example.com. Choose this if your DNS provider doesn't support apex CNAME flattening, or if you need cookie isolation (cookies set on www. won't leak to other subdomains like app.example.com).
Off — Both hosts serve content. Don't use this in production. Search engines will see two indexable copies of your site.
Either apex or www works for SEO — Google treats both as valid canonical choices. Pick one and stick with it. Switching later forces re-crawling and temporary ranking dips.
How the redirect actually works
When a request hits the non-canonical host:
- Encited (formerly LovableHTML) responds with
301 Moved Permanently - The
Locationheader points to the same path on the canonical host - Query strings and the path are preserved exactly
So https://www.example.com/blog/post?ref=twitter → https://example.com/blog/post?ref=twitter if apex is canonical.
Verify it's working
curl -sI https://www.example.com/some-page# Expect:# HTTP/2 301# location: https://example.com/some-page
Don't combine this with a page-level redirect that also rewrites the host — they'll fight each other and cause redirect loops. Use the Primary domain setting for the apex/www choice, and use 301 redirects only for path-level forwards.
Common mistakes
- Setting both DNS records but no primary — both versions resolve, both get indexed, ranking gets diluted.
- Switching primary host mid-launch — every existing backlink and cached search result now goes through one extra redirect hop. Pick the canonical host before you start building inbound links.
- Forgetting to update sitemaps — your sitemap should list the canonical host. If it lists the non-canonical one, every URL in it is a redirect.
