Guides /Domains
Domains

www vs Non-www: Which Should You Use for Your Website?

April 5, 20256 min readHostBible Team

Whether your website should use www.yourdomain.com or just yourdomain.com is one of those questions that sparks more debate than it warrants. For SEO purposes, it genuinely doesn't matter which you choose, what matters is that you pick one, configure it correctly, and redirect the other version consistently. This guide explains the technical differences, when each approach has practical advantages, and how to set it up properly.

The Technical Difference

www is a subdomain. From a DNS perspective, www.yourdomain.com is a CNAME or A record that you configure separately from the root domain (yourdomain.com). The non-www version uses the bare domain (also called the "apex" or "naked" domain), which points directly to an A record containing your server's IP address.

This distinction matters for one specific technical reason: cookies. Cookies set on yourdomain.com are automatically sent with requests to all subdomains, including www, app, api, etc. Cookies set on www.yourdomain.com stay scoped to that subdomain. If you have a web application with sensitive session data on a subdomain, using a non-www root can cause unintended cookie sharing. For most small business websites, this is irrelevant, but for SaaS products or web apps, it's worth knowing.

SEO: Does It Actually Matter?

Google treats www.yourdomain.com and yourdomain.com as separate URLs. If both are accessible without a redirect, Google may index both versions and split your link equity between them, a problem called duplicate content. This is the real SEO risk, and it's solved by picking one version and redirecting the other, not by choosing www vs non-www.

Once you've set up a canonical redirect (301 from the non-preferred version to the preferred one) and set your preferred domain in Google Search Console, search engines treat them identically. There is no SEO benefit to using www over non-www or vice versa. The decision is purely a technical and branding preference.

When www Has Technical Advantages

DNS flexibility. The www subdomain can be a CNAME record, which means it can point to a CDN, load balancer, or hosting provider by hostname (e.g., www CNAME yoursite.cdn-provider.com). Apex/root domains can only use A records (IP addresses), which means you can't CNAME the root to a CDN hostname, you need a static IP. Many CDNs and cloud hosting providers work around this with "ANAME" or "ALIAS" records, but not all DNS providers support them.

Large-scale infrastructure. For high-traffic websites using complex DNS routing (geolocation routing, failover routing, multiple server pools), www gives you more flexibility. CDNs like Cloudflare, Fastly, and Akamai often recommend www because it's easier to route via DNS. If you use Cloudflare, this limitation is less relevant, Cloudflare's Argo/proxy mode handles root domains with CNAME flattening.

When Non-www Is the Better Choice

Simplicity and branding. Non-www URLs are shorter and cleaner for marketing materials, business cards, and verbal communication. "Visit example.com" is simpler than "visit www.example.com." Most modern users type the bare domain anyway and expect it to work. For small businesses, non-www is usually the right default.

You're on shared hosting with a static IP. If your hosting provider assigns you a static IP and you don't use a CDN, there's no technical reason to use www. The root domain with an A record works just as well, and the non-www URL is cleaner to communicate.

How to Set Up the Redirect Correctly

The critical step is ensuring one version redirects to the other with a permanent 301 redirect. In Apache (cPanel hosting), this is done in your .htaccess file. To redirect www to non-www:

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

To redirect non-www to www, reverse the logic:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain\.com [NC]
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [L,R=301]

In WordPress, you can set the preferred URL under Settings > General (WordPress Address and Site Address). WordPress will then handle the redirect, but adding the .htaccess rule as well ensures the redirect happens at the server level before WordPress even loads, which is faster and more reliable.

DNS Configuration for Both Versions

Regardless of your preferred version, configure both in DNS so both are accessible before the redirect fires. For non-www as the preferred version: add an A record for @ (root) pointing to your server IP, and add an A record for www also pointing to your server IP (or a CNAME for www pointing to yourdomain.com). The redirect in .htaccess or your web server config then sends www traffic to non-www.

Test your setup using redirect-checker.org or by running curl -I http://www.yourdomain.com from the command line. You should see a 301 redirect to your canonical URL. Check both HTTP and HTTPS versions, since some configurations redirect www but not HTTP-to-HTTPS simultaneously.

Setting Your Canonical Domain in Google Search Console

After setting up the redirect, log in to Google Search Console and add both versions of your domain as properties (www and non-www). In the older interface, there was a "preferred domain" setting, this has been replaced by Google using your redirects and canonical tags as signals. Make sure your sitemap URL uses your preferred domain, and that all internal links use the canonical version consistently.

If you've been running your site for a while with inconsistent www usage, run a crawl with Screaming Frog or Ahrefs to identify any internal links using the wrong version. Fixing these to use the canonical URL consistently helps consolidate link equity and avoids confusing crawlers.

Register and Manage Your Domain

HostBible offers domain registration with full DNS management, making it easy to configure www, non-www, and all the records your site needs.

Search Domain Names