Fix Duplicate HTTP and HTTPS URLs
Why duplicate HTTP and HTTPS URLs happen
After you install a certificate, the old HTTP site often keeps working. A page can then answer on four addresses: http://example.com, http://www.example.com, https://example.com and https://www.example.com. Search engines may treat them as separate URLs, split links between them, or pick the wrong one to show.
Step 1: Decide the canonical form
Choose https plus either www or non-www, and stay with it. Everything below enforces that choice. Make sure the certificate covers both host names, otherwise the redirect from the other one fails with a warning.
Step 2: Add 301 redirects
Nginx, one block for all HTTP traffic and one to normalise the host:
server {
listen 80;
server_name example.com www.example.com;
return 301 https://example.com$request_uri;
}
server {
listen 443 ssl;
server_name www.example.com;
# ssl_certificate lines here
return 301 https://example.com$request_uri;
}
Apache .htaccess:
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [L,R=301]
Use 301, not 302, so the change is treated as permanent. Keep it to one hop. A chain from http to http-www to https adds latency and can lose signals.
Step 3: stop duplicate HTTP and HTTPS URLs on the rest of the site
- Canonical tags:
<link rel="canonical" href="https://example.com/page">on every page. - Internal links and images: use https or relative paths.
- XML sitemap: list only the final https URLs and resubmit it.
- Search Console: add the https property and check coverage there.
- Cookies and CMS settings: set the site URL to https so the CMS stops emitting http links.
Step 4: Add HSTS once stable
HSTS tells browsers to use https without asking first. Start with a short max-age and raise it when everything works:
Strict-Transport-Security: max-age=31536000; includeSubDomains
Be careful with includeSubDomains and preload. Every subdomain must work over https. Check the header with the Security Headers checker.
Test the result
Enter each of the four variants into the HTTPS Redirect checker. Each should show one 301 and end on the same https URL. Then use the SSL Checker to confirm the certificate covers both host names.
Finding leftover duplicates
Search your site with a crawler and filter for URLs that start with http. Look at the Pages report in Search Console for duplicates where Google chose a different canonical than you did. Check old backlinks that point at http URLs, because they pass through your redirect and are worth keeping. Review any subdomains, staging sites and image CDNs, since they often keep serving http. Finally, re-test after every plugin or theme change that might rewrite URLs, as a CMS update can bring back old links.
Related reading: leftover HTTP internal links and SSL for www and non-www.
Frequently Asked Questions
Is a canonical tag enough without redirects?
It is a hint, not a command. Redirects are stronger and also protect visitors. Use both.
Should I use 301 or 302?
301 for a permanent move to https. 302 signals a temporary change.
Will the redirect hurt my rankings?
A clean one-hop 301 passes signals to the https URL. Problems come from chains, loops and leaving both versions live.
Do I need to redirect the www host too?
Yes. Redirect whichever host form you did not choose to the one you did.
Does a canonical tag fix duplicates on its own?
It is a hint, and it only works if the tag is on the duplicate page and points at the canonical one. A redirect is stronger because it removes the duplicate address.
Should the old http address return 301 or 308?
301 is the safe choice for search engines and old clients. 308 is permanent too and keeps the method, but 301 is what the tools and docs expect.
Do I need HSTS to stop duplicates?
No, but it helps. Once a browser has seen the HSTS header it stops trying http at all, which removes one variant for returning visitors.
How do I find duplicates I missed?
Crawl the site and compare the http, https, www and non-www versions of each URL. A redirect checker that follows one hop shows chains that hide a duplicate.
✅ Post-Installation Verification & SEO Checklist
After applying the steps above, run through this 5-point checklist to prevent browser warnings and protect your Google SEO rankings:
- Verify full CA chain trust and TLS 1.3 support using our Live SSL Checker.
- Scan for Mixed Content HTTP links and check HSTS/CSP headers on Security Headers Checker.
- Enforce a permanent 301 HTTP-to-HTTPS redirect with our HTTPS Redirect Generator.
- Confirm both root and
wwwversions resolve cleanly to one canonical HTTPS URL. - Verify your HTTPS property and
sitemap.xmlinside Google Search Console and Bing Webmaster Tools.