troubleshooting 2026-12-02 ⏱ 4 min read

Fix SSL Certificate for WWW and Non-WWW Domains

Fix SSL Certificate for WWW and Non-WWW Domains

The most common SSL complaint is oddly specific: the secure site works, but only without the www, or only with it. The cause is always the same. The certificate lists one hostname, visitors use the other, and the browser correctly reports a name mismatch. The fix has two parts: a certificate that covers both names, and a redirect that picks one.

Why one SSL certificate must cover www and non-www

To DNS, example.com and www.example.com are different names that happen to point at the same server. TLS does not care about your intentions: the certificate must explicitly list every hostname visitors type. A certificate issued for only example.com produces a name-mismatch warning on https://www.example.com, and no redirect can prevent it, because the warning happens before the redirect.

Check what your SSL certificate covers for www and non-www

echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null \
  | openssl x509 -noout -ext subjectAltName

The SAN list should show both example.com and www.example.com. The SSL Checker shows the same list from the outside. Test each hostname explicitly, because the served certificate can differ per name on shared hosting.

Issue one certificate for both names

With Certbot, list both names in the same command:

certbot certonly -d example.com -d www.example.com --nginx

Browser issuance works the same way: at TryFreeSSL, add both names to the order and validate each. Both names in one certificate means one renewal and one install. Do not issue two separate single-name certificates; it doubles maintenance for no benefit.

Redirect everything to one canonical version

With both names secured, pick one canonical version and 301 the other to it. Whether you keep www or drop it is preference; consistency is what matters. All four variants should land on one URL in a single hop:

http://example.com      -> https://example.com
http://www.example.com  -> https://example.com
https://www.example.com -> https://example.com

For Nginx:

server {
    listen 443 ssl;
    server_name www.example.com;
    ssl_certificate     /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    return 301 https://example.com$request_uri;
}

Generate the matching rules for Apache or your panel with the HTTPS Redirect Generator.

Update what points at the old name

  1. Set the canonical URL in your CMS settings to the chosen HTTPS version.
  2. Update canonical tags and your sitemap so they reference one version only.
  3. Confirm the HTTPS version is the property you monitor in Search Console.

Related reading: free SSL for a subdomain and duplicate HTTP and HTTPS URLs.

Frequently Asked Questions

Should I use www or non-www as canonical?

Either works. Non-www is shorter; www makes cookie scoping slightly simpler on some setups. Pick one and redirect the other forever; changing later costs more than the choice itself.

Does a wildcard certificate cover the apex domain?

No. *.example.com covers www.example.com but not the bare example.com. Include the apex as a second name in the same order.

Why does the redirect not fix the certificate warning?

Because TLS negotiation happens before the server can send a redirect. The browser validates the certificate for the name typed, so the redirect target never gets a chance. Both names need valid certificates regardless of redirects.

Do I need HSTS on both names?

Set HSTS on the canonical HTTPS host. If you later want includeSubDomains and preload, every subdomain needs valid HTTPS permanently, so only enable it once the whole setup is stable.

Should I use www or non-www as canonical?

Either works. Non-www is shorter; www makes cookie scoping slightly simpler on some setups. Pick one and redirect the other for good, because changing later costs more than the choice itself.

Does a wildcard certificate cover the apex domain?

No. *.example.com covers www.example.com but not the bare example.com. Include the apex as a second name in the same order.

Why does the redirect not fix the certificate warning?

Because TLS negotiation happens before the server can send a redirect. The browser validates the certificate for the name typed, so both names need valid certificates whatever the redirects say.

Do I need HSTS on both names?

Set HSTS on the canonical HTTPS host. If you later want includeSubDomains and preload, every subdomain needs valid HTTPS permanently, so enable it once the whole setup is stable.

Does this affect email or other services on the domain?

No. The certificate covers hostnames for TLS on the web. Mail authentication is separate and uses SPF, DKIM and DMARC records.

🔒 Test Your Website SSL Certificate Now
Run Free SSL Check →

✅ 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 www versions resolve cleanly to one canonical HTTPS URL.
  • Verify your HTTPS property and sitemap.xml inside Google Search Console and Bing Webmaster Tools.
Technically Reviewed by TryFreeSSL Security Team
Last updated: 2026-12-05
About Us →

Free SSL Certificates, Live SSL Checker & CSR Generator

Issue trusted Let's Encrypt SSL certificates in 60 seconds with zero server setup.

Related Articles

🤖 TryFreeSSL AI Assistant