Your site can technically be reached at both www.yourdomain.com and yourdomain.com. Leaving both live splits your SEO and creates duplicate content in search engines’ eyes. The fix is to choose one and redirect the other. Here’s how.

Pick your preferred version

There’s no SEO advantage to either www or non-www — pick whichever you prefer and be consistent. Non-www is a touch shorter and increasingly common; www has some technical advantages for very large sites. For most people, it’s simply a style choice.

Set it in WordPress first

Go to Settings → General and make sure both WordPress Address and Site Address use your chosen version consistently (both https://yourdomain.com or both https://www.yourdomain.com). This tells WordPress which version is canonical.

Enforce it with .htaccess

Settings alone don’t redirect the other version — you need a server rule. Add one of these to the top of your .htaccess file, above the WordPress block.

To force non-www (redirect www to bare domain):

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

To force www (redirect bare domain to www):

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

The 301 makes it a permanent redirect, which is what passes SEO value to the chosen version.

Combine it with HTTPS

While you’re in .htaccess, it makes sense to force HTTPS at the same time so every visitor lands on the secure, canonical version regardless of how they typed the address. Our SSL guide covers the HTTPS redirect rule.

Test both versions

After saving, type each version into your browser — with www, without, with http, with https — and confirm they all end up at your one canonical address. A quick check across all four combinations confirms the redirect is airtight.

Update your search console

Tell Google Search Console which version is canonical and update your sitemap so it points to the preferred URLs. This keeps your indexing tidy and consolidates your ranking signals.

It’s a small change that quietly tidies up your SEO. If .htaccess edits make you nervous, we’re happy to add the redirect for you.

Was this article helpful to you?

admin

Leave a Reply

You must be logged in to post a comment.