Before launching a new website, one decision you will have to choose is between the www and non-www URLs.
What is the difference?
The www vs non-www question is mostly about preference. There is no major difference in how users experience your site, but www domains can have some slight technical benefits for performance and cookie handling in more advanced setups.
From an SEO standpoint, the differences are incredibly small. What matters most is choosing one version and being consistent.
The www URL format of your domain could appear like this:
www.mydomain.com — example www URL
Using the non-www version, your domain will look like this:
www.mydomain.com — example www URL
From a technical SEO point of view, these two URLs are not the same host. Search engines treat them as separate unless you set a clear preferred version and redirect consistently.
No matter which URL format you choose, it’s important to create rewrite rules in your .htaccess file so that all traffic is redirected to your preferred www or non-www version.
If you’re unsure which format to use, the next sections will help you decide and implement the redirect safely.
www or Non-www: Which Should I Choose?
The truth is, whichever you choose doesn’t really matter as much as enforcing one version. It’s not as critical as moving from HTTP to HTTPS. It mostly comes down to branding and aesthetics.
Non-www URLs are shorter and can look cleaner, which is why many modern brands prefer them. Traditional setups and larger sites sometimes favor www for historical or technical reasons.
Neither format has a built-in SEO advantage, and neither is inherently faster. What matters is:
- Pick one version (www or non-www).
- Set your redirects so that all traffic ends up on that version.
- Use the same version in your internal links, canonical tags, and sitemaps.
How to Force WWW to Non-WWW with .htaccess
To edit your .htaccess file, you need access to your site’s root directory. You can do this through your hosting control panel (cPanel > File Manager) or via an FTP client.
Personally, I prefer using an FTP client like
Fetch
or
Cyberduck.
This makes it easy to download and back up your existing .htaccess file before making any changes.
Always back up your current .htaccess file first. A small typo in this file can cause 500 errors across your site.
Step-by-Step: Redirect www to Non-www
If you’d like to force www to redirect to non-www, use the following code. This rule takes any request that starts with www. and permanently redirects it to the same path on the non-www version of your domain.
Copy and paste this at the top of your .htaccess file (above existing WordPress or CMS rules):
# Redirect www to non-www over HTTPS
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
If your site is still using plain HTTP (not recommended), you can replace the third line with:
# Redirect www to non-www over HTTP
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
After saving the file, clear your browser cache and test a URL like
http://www.yourdomain.com/sample-page. It should now automatically redirect to
https://yourdomain.com/sample-page.
To verify that the redirect is working properly and that there are no redirect loops, you can:
- Paste the URL into your browser’s address bar and watch the final URL.
- Use a redirect checker tool.
- Run a quick SEO audit with Seobility to confirm everything is clean.
Conclusion
In this article, you learned the practical differences between www and non-www URLs, how they impact SEO, and how to enforce your preferred version using a simple .htaccess rule.
By setting up a 301 redirect from www to non-www (or vice versa), you:
- Prevent duplicate content issues.
- Keep your site’s URLs consistent.
- Make things clearer for both users and search engines.
Choose the format that fits your brand, implement the redirect safely, and you’ll have one more technical SEO detail checked off your list.