Custom domains and TLS
Pointing a domain at your host, choosing between apex and www, and getting certificates that renew themselves.
Pointing the domain
Hosting providers give you either an IP address or a hostname to point at. Use an A/AAAA record for an IP, and a CNAME when the provider manages a pool of addresses behind their own name - that is far more robust, but a CNAME is not allowed at the apex, which is why apex support needs provider-side flattening or an ALIAS record.
; recommended shape: www is the CNAME, apex redirects to it
example.com. 300 IN A 203.0.113.10 ; or ALIAS to host.example.net
www.example.com. 300 IN CNAME host.example.net.
; alternative: both served, one canonical
example.com. 300 IN A 203.0.113.10
www.example.com. 300 IN A 203.0.113.10- Pick one canonical hostname and redirect the other with a single 301 - no chains.
- Add the custom domain in the hosting panel too, or the request arrives at the edge with an unknown host header.
- Remove the provider's default domain from the sitemap and canonical tags; it should redirect or 404, not compete.
- Verify with the host header before the DNS change is global:
curl -H "Host: example.com" https://203.0.113.10/ -kI.
Certificates that renew themselves
Modern hosts issue and renew certificates for you once the domain resolves correctly. If you manage TLS yourself, automate issuance and put a monitoring check on the expiry date - an expired certificate is still one of the most common self-inflicted outages.
# is the chain complete, and when does it expire?
echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null \
| openssl x509 -noout -subject -issuer -dates
# does the www variant work too?
echo | openssl s_client -connect www.example.com:443 -servername www.example.com 2>/dev/null \
| openssl x509 -noout -subject| Certificate | Covers | Watch out for |
|---|---|---|
| Single name | example.com | Does not cover www - a common padlock warning |
| SAN list | Each name listed | Add every subdomain you actually serve |
| Wildcard | *.example.com | Never covers the bare apex; include both |
| Managed by the platform | Every configured domain | Fails silently if DNS points elsewhere |
Redirect HTTP to HTTPS at the edge or in the server block, then send Strict-Transport-Security so browsers stop trying plain HTTP at all.
Launch checklist
- Both hostnames resolve, and one redirects to the other with a 301.
- TLS is valid on every hostname you serve, with a complete chain.
- The canonical URL in your pages, sitemap and feeds matches the live hostname.
- HTTP redirects to HTTPS, and HSTS is enabled once you are certain.
- A 404 for a missing path returns 404 - not the homepage with a 200 status.
FAQ
Apex or www?
Why does my certificate look invalid on www?
Related
Static versus dynamic hosting HTTPS and TLS
Last refreshed 2026-09-18.