Redirect www and apex to one host on Netlify
Why it matters
Both names serve the site, so search engines see duplicate pages and logins, cookies and HSTS are split between two hosts. Pick one canonical host and permanently redirect the other to it.
The fix
- Set the canonical name as the primary domain; Netlify redirects its www/apex counterpart automatically. Remove the other name if it is listed as a separate alias.
- If both still serve the site, add the rule below to _redirects in the publish directory and redeploy.
_redirects
https://www.example.com/* https://example.com/:splat 301! The examples use example.com. Replace it with your own domain.
Related
- Reported by the HTTP to HTTPS redirect check
- Serve the site over HTTPS
- Stop redirecting HTTPS to HTTP
- Redirect HTTP to HTTPS
- Fix the broken HTTPS redirect chain
- Shorten the redirect chain
- Fix the HTTP redirect chain
- Redirect HTTP straight to HTTPS
- Answer HTTP with a redirect to HTTPS
- Make the www or apex name work over HTTPS
Scan your domain to see whether this applies to you.