Docs

One address, with or without www

One address, with or without www

example.com and www.example.com are two different addresses. People type both, and other sites link to both. If both show the site, Google sees two copies of every page and splits links and ranking between them, analytics counts two hostnames, and a visitor logged in on one is logged out on the other.

Pick one as the main address and let the other answer with a permanent 301 redirect to it. Which one you pick does not matter for ranking; being consistent does. The site checklist tests the variant you are not using.

What the checklist expects

The other variant Result
redirects to the main address OK
shows the site without redirecting warning: two copies of the site
has a certificate error fail: visitors who type it see a security warning instead of your site
does not exist (no DNS record) info: fine as long as nobody types or links to it

The certificate case catches many sites: the redirect is in place, but the certificate only covers example.com, so https://www.example.com fails before the redirect can happen. The redirecting variant needs a valid certificate too.

Check it yourself

Replace example.com with your site. If your main address is www.example.com, test example.com instead:

dig +short www.example.com
curl -sI https://www.example.com/some/page | grep -iE '^(HTTP|location)'
curl -sI http://www.example.com/some/page | grep -iE '^(HTTP|location)'

Fixed looks like this, in one hop and with the path kept:

HTTP/2 301
location: https://example.com/some/page

If curl instead prints an error such as SSL: no alternative certificate subject name matches target host name, the certificate does not cover that variant. If dig prints nothing, the variant has no DNS record.

How to fix

There are three parts, in this order: a DNS record for the other variant, a certificate that covers both names, and the redirect. Pick what you have access to.

DNS provider

The other variant needs a DNS record that points at the same server (or CDN) as the main address. Most often that is www:

Name Type Value
www CNAME example.com.

If your provider does not allow a CNAME there, use an A record with the same IP address as the main domain (for example 203.0.113.10), plus an AAAA record if the main domain has one.

If the main address is www.example.com and the bare example.com has no record, add an A record for @ with the server's IP. A CNAME is not allowed on the bare domain unless your provider offers ALIAS, ANAME or CNAME flattening.

New records usually work within minutes; an existing record that you change can take as long as its TTL.

WordPress

WordPress already redirects to the host in Settings → General → Site Address (URL) (its canonical redirect), as long as the request for the other variant reaches the same WordPress installation.

  1. Set WordPress Address (URL) and Site Address (URL) to the same main address, for example https://example.com.
  2. Make sure the other variant has a DNS record and a certificate (see the DNS tab and your hosting tab). Without a certificate the browser stops before WordPress can redirect.
  3. Clear the page cache.

If the other variant shows a different site or a hosting placeholder page, it is not pointed at your WordPress site. Fix that in the hosting panel.

cPanel

  1. Certificate: in Security → SSL/TLS Status, check that both example.com and www.example.com are listed as covered. AutoSSL includes www when its DNS record points at the server; click Run AutoSSL after adding the record.
  2. Redirect: add this at the top of the .htaccess in the site's root (File Manager, with Show Hidden Files on). It redirects www to the bare domain and http:// to https:// in one hop:
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [L,R=301]

For the opposite direction (bare domain to www), change the second condition to RewriteCond %{HTTP_HOST} !^www\. [NC] and the target to https://www.example.com%{REQUEST_URI}.

cPanel also has Domains → Redirects, but its www options are easy to set up as a loop. The .htaccess rule is more predictable.

Plesk

  1. Certificate: in Websites & Domains → example.com → SSL/TLS Certificates, when you issue or renew the Let's Encrypt certificate, include the www subdomain.
  2. Redirect: open Websites & Domains → example.com → Hosting & DNS → Hosting (Hosting Settings in older versions). Under Preferred domain, choose example.com or www.example.com. Plesk then sends a permanent 301 redirect from the other one.
  3. Click OK.

nginx

In your site's file (/etc/nginx/sites-available/example.com on Debian and Ubuntu, /etc/nginx/conf.d/example.com.conf on Rocky, Alma and CentOS), give the other variant its own HTTPS server block that only redirects:

server {
    listen 443 ssl;
    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;
}

server {
    listen 80;
    listen [::]:80;
    server_name example.com www.example.com;

    return 301 https://example.com$request_uri;
}

The main server block keeps only server_name example.com;. The certificate must cover both names; with Certbot:

sudo certbot certonly --nginx -d example.com -d www.example.com
sudo nginx -t && sudo systemctl reload nginx

Apache and LiteSpeed

With server access (Apache). Add a virtual host for the other variant that only redirects (in /etc/apache2/sites-available/ on Debian and Ubuntu, /etc/httpd/conf.d/ on Rocky, Alma and CentOS):

<VirtualHost *:443>
    ServerName www.example.com
    SSLEngine on
    SSLCertificateFile    /etc/letsencrypt/live/example.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
    Redirect permanent / https://example.com/
</VirtualHost>

Remove www.example.com from the ServerAlias of the main virtual host, get a certificate for both names (sudo certbot --apache -d example.com -d www.example.com) and reload:

sudo apachectl configtest && sudo systemctl reload apache2

(httpd instead of apache2 on Rocky, Alma and CentOS.)

Without server access (shared hosting, LiteSpeed). Use the .htaccess rule from the cPanel tab; it works on any host that reads .htaccess.

Cloudflare

  1. In DNS → Records, make sure the other variant exists and is Proxied (orange cloud). Redirect rules only run on proxied traffic. Cloudflare's edge certificate covers example.com and www.example.com automatically.
  2. Go to Rules → Overview, click Create rule and choose Redirect Rule (on some accounts: Rules → Redirect Rules). Start from the template Redirect from WWW to root, or set it up yourself:
    • When incoming requests match: Hostname equals www.example.com
    • Then: Dynamic, expression concat("https://example.com", http.request.uri.path)
    • Status code: 301, and turn on Preserve query string
  3. Deploy.

Shopify

Shopify connects both example.com and www.example.com and redirects all of them to the primary domain. In Settings → Domains, check that both are listed as connected and that the one you want is the primary domain (Change primary domain if not). Shopify issues the certificates once the DNS records point at Shopify.

Other hosted platforms

Wix, Squarespace and Webflow also redirect every connected domain to the one you set as primary or default in their domain settings. If the checklist reports a certificate error or two copies, the other variant is usually missing from the platform's domain list, or its DNS record still points somewhere else.

Confirm the fix

Run the commands from Check it yourself again, then open the target in PulseKeeper and click Check now on the Checklist tab. If the checklist shows an extra hop, see Redirect HTTP to HTTPS for how to reach the main address in one step.