🌐
blog.cat.ssl

One SSL certificate for both www and non-www: setting it up correctly

19.11.2026
← All articles

Most people see example.uz and www.example.uz as the same site, but to a browser and to SSL they are two separate names. If the certificate covers only one, visitors using the other get a name mismatch error. It is a sneaky problem, because owners test the variant they type every day, while customers arrive through a business card, an ad or an old link that uses the other one.

One certificate, two names

Modern certificates carry a Subject Alternative Name (SAN) list that can hold several names, so you do not need two certificates: one certificate listing both names is enough. Let's Encrypt issues these for free, and many hosting panels have an option like "include www alias" when issuing. A wildcard *.example.uz covers www.example.uz but not the bare example.uz, and Let's Encrypt only issues wildcards via DNS validation, so a plain two-name certificate is simpler for a normal site.

Get DNS ready first

Let's Encrypt validates every name before issuing, usually by requesting /.well-known/acme-challenge/ on each one. If www has no DNS record or points elsewhere, issuance fails or the certificate comes out with only one name. Check both:

dig +short example.uz A
dig +short www.example.uz

Both must lead to the same server IP. In the sayt.uz cabinet you can add or edit records on the domain page: an A record for @ and either a CNAME for www pointing to the apex or an A record with the same IP.

On your own server with certbot

sudo certbot --nginx -d example.uz -d www.example.uz
sudo certbot certificates

The first command issues one certificate with both names; if an older single-name certificate exists, certbot offers to expand it. The second should show both under Domains:. On Apache, use --apache instead of --nginx; certbot also sets up automatic renewal, and both names renew together as one certificate.

Pick a main address and redirect the other

Serving the same site on two addresses is also bad for search engines. Choose one canonical address and send the other there with a permanent 301 redirect, then use that address consistently in links, the sitemap and ads. Note that a redirect from https://www.example.uz only works after the browser has established a secure connection to that name, so the redirected name must be in the certificate too. In Nginx:

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

On shared Apache hosting, in .htaccess:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.uz$ [NC]
RewriteRule ^(.*)$ https://example.uz/$1 [R=301,L]

Example: a furniture shop's business cards

A Tashkent furniture shop launched misol.uz with a certificate for the bare name only. A month later new business cards arrived printed with www.misol.uz, and customers started calling to ask whether the site had been hacked. The certificate was reissued with the www alias and a 301 redirect from www to the main address was added, so every printed and online address now lands on one secure page.

Verify all four variants

Test http:// and https://, with and without www. Each should end at the single main HTTPS address without long redirect chains:

curl -sI http://www.example.uz | grep -i location
curl -sI https://www.example.uz | grep -i location

On sayt.uz hosting, Let's Encrypt certificates are free and renew automatically, so once the www alias is added correctly, both names stay covered on every renewal. Remember to add new subdomains to the certificate as well.

Related articles

📱 SSL errors on old Android devices: causes and what you can do 🔍 Checking an SSL certificate with OpenSSL: the commands you actually need ⚛️ Post-Quantum Encryption (ML-KEM): What Is Changing in TLS 🧭 Hundreds of domains on one server: how SNI keeps SSL from mixing up
🌐 Language
🇺🇿 O'zbek 🇺🇿 Ўзбек 🇷🇺 Русский 🇬🇧 English ✓