WWW or non-WWW: pick a single address for your site
Your site works with and without www? Pick one main address and avoid inconsistent redirects.
Should you use WWW?
Both setups are valid: https://example.com and https://www.example.com. What matters is to pick one main version and redirect the other one to it. Choosing one over the other does not, by itself, give a guaranteed SEO advantage.
If both versions serve the same page without a redirect, they multiply the reachable addresses and blur the signals sent to search engines. If one points elsewhere or does not work, visitors get inconsistent results.
Pick the main address
- Look at the addresses already used in navigation, emails, the sitemap and Google Search Console.
- Pick a permanent address, for example
https://example.com. - Confirm that both DNS names and their HTTPS certificates work.
- Set up a single permanent redirect from the other name to the chosen address, keeping the path and parameters.
- Align internal links, the sitemap and canonical tags with the final address.
Cloudflare: non-WWW example
In Rules → Redirect Rules, create a rule targeting www.example.com:
- Condition:
(http.host eq "www.example.com") - Dynamic target:
concat("https://example.com", http.request.uri.path) - Status code:
301 - Preserve query string: on.
This rule sends the www variant to the main domain. If http://example.com must also move to HTTPS, a single condition that also covers HTTP avoids two hops. If Always Use HTTPS is on, http://www will often go through https://www first: see the HTTP to HTTPS guide to do it all in a single redirect.
Note: Cloudflare rules only apply to proxied hostnames. If the site runs on a Worker, it may be better to handle this redirect in the Worker.
Apache and LiteSpeed
In a compatible .htaccess file, to redirect the www version to the non-www version:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L]
On its own, this rule does not handle http://example.com: combine the rules consistently to get a single hop from every variant. With OpenLiteSpeed, confirm that .htaccess rules are supported and enabled.
Nginx
In the server blocks that receive requests for www.example.com, return the main address directly:
return 301 https://example.com$request_uri;
Over HTTPS, the www server block must present a valid certificate before it can send the redirect.
What about subdomains?
forum.example.com is a separate site or service: it usually does not need a www.forum.example.com version. That is why Redirect Audit tests only HTTP and HTTPS for subdomains, and all four variants for main domains.
Final check
Test your domain in Redirect Audit: the variants should all reach the same HTTPS address. Also test an inner page, so you do not accidentally redirect all content to the home page.
These examples are a starting point: adapt them to your setup and test them before applying them to a live site.