Last updated: November 2026
Many websites can be opened in two ways: www.example.com and example.com. Visitors rarely notice the difference, but search engines treat them as two separate addresses. This guide explains what the difference is, how to choose, and how to make sure that your site opens at only one of them.
What Is the Difference?
The part of an address after the dots is called a hostname. In www.example.com, the www is a subdomain of example.com. The version without it, example.com, is called the bare, naked, or apex domain. Both can show exactly the same website, but to a browser or a search engine, they are different addresses.
Why It Matters
If both versions open without a redirect, your pages exist at two addresses. This can cause several small problems:
- Other websites may link to either version, so your links are split between two addresses.
- Search engines may crawl and show the same page twice.
- Your analytics and Search Console reports can become confusing.
The fix is simple: choose one version as your main (preferred) address and redirect the other one to it.
Is One Better for SEO?
No. Google has said that you can use either one. What matters is that you pick one and use it consistently. Neither choice gives you a ranking advantage.
Reasons to Choose www
- DNS flexibility. The DNS standard does not allow a CNAME record on the bare domain, so www is easier to point at some hosting and CDN services. Many providers now offer ways around this, so it matters less than it used to.
- Cookie control. Cookies set on the bare domain are sent to all of its subdomains. With www, you can serve images and files from a separate subdomain that does not receive those cookies.
- It looks familiar to many visitors, especially on older or more traditional sites.
Reasons to Choose Non-www
- It is shorter and cleaner, which is easier to type, say, and print.
- Modern hosting handles it well, so the technical drawbacks are small for most websites.
How to Decide
- If your site is already live and has been for a while, keep the version you use now. Changing it means extra work and little benefit.
- If you are starting a new site, pick the one you like. Either one is fine.
- If your hosting or CDN provider recommends one, follow its advice.
How to Set Up the Redirect
- Make sure both versions work. Both the www and the non-www address must point to your server in DNS, and your security certificate (HTTPS) must cover both. Otherwise, visitors who type the other version may see a security warning before the redirect.
- Add a 301 redirect from the version you do not want to the version you do want. A 301 redirect means "moved permanently".
- Check the result with a tool.
On an Apache server, you can add the redirect to your .htaccess file. Back up the file first. To send non-www visitors to www:
# Redirect example.com to www.example.com
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
To send www visitors to non-www instead:
# Redirect www.example.com to example.com
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]
Replace example.com with your own domain. You can also create the code with our Htaccess Redirect Generator. Write a short comment above your rule that says what it does, so that you remember later why it is there.
Not every site uses .htaccess. Many hosting panels, website builders, and CDN services have a setting for this, sometimes called "force www" or "redirect to preferred domain". If your host already does it, do not add a second rule on top, because two redirects that conflict can create a loop.
Keep Everything Consistent
A redirect is only the first step. Make sure that the rest of your site uses the same version:
- Canonical tags should point to the preferred version of each page.
- Internal links should use the preferred version.
- Your XML sitemap should list only preferred addresses. See our guide on how to create and submit an XML sitemap.
- Google Search Console: the old "preferred domain" setting is gone, so rely on your redirect and canonical tags. Adding your site as a Domain property lets you see data for both versions together.
- Links you control, such as social profiles and business listings, should use the preferred version.
How to Test Your Redirect
- Type the version you do not use into your browser. It should land on your preferred version.
- Enter your address in our www Redirect Checker to see how it behaves.
- Paste both versions into our Server Status Checker. The unwanted version should return 301, and the preferred version should return 200.
- View the page source and look for the canonical tag. You can use our Get Source Code of Webpage tool. The tag should show your preferred address.
Common Mistakes
- Both versions return 200. This means that no redirect exists, and your pages are available at two addresses.
- Using a 302 instead of a 301. A 302 is meant for temporary moves. Use a 301 for a permanent choice.
- A redirect loop. If the browser shows "too many redirects", two rules are fighting each other, for example one rule in .htaccess and another in a plugin or hosting panel.
- A redirect chain. For example, http non-www goes to http www, then to https www. Where you can, send visitors to the final address in one step.
- The certificate covers only one version. Visitors then see a warning before the redirect works.
- A sitemap or canonical tags that use the other version. Search engines get mixed signals.
Changing the Preferred Version on an Existing Site
If you decide to switch, plan it carefully. Add the 301 redirect, update canonical tags, internal links, and the sitemap, and add the new version to Search Console. With correct redirects, your pages should keep their position, but it can take search engines some time to catch up.
Frequently Asked Questions
Which is better, www or non-www?
Neither is better for search. Choose one and be consistent.
Can I use both without a redirect?
Technically yes, but it is not recommended, because your pages then exist at two addresses.
Should I redirect with a 301 or a 302?
Use a 301, because this is a permanent choice.
Do I need to do anything in Google Search Console?
Add your site as a Domain property to see both versions, and submit a sitemap that lists your preferred addresses.
Next Steps
Run your site through our www Redirect Checker today. If you find a problem, fix it using the steps above, and then confirm the result with the Server Status Checker.