SEO Friendly URL Part3: www vs non-www

www vs non-www

This is the decision that every webmaster have to make when seting up a new website. From an SEO point of view, there’s no benifit of choosing one or other. Google does not care which one you use. But you have to know the technical difference.

You will want to use www domain name mainly becuase you have a very large website (millions of page views per day). In order to withstand such large amount of traffic, you would likely want to set up DNS redundancy. But non-www domains can’t have DNS redunancy because there’s no way to define a cname record for them.

Avoid Duplicate Content

Whether you choose www or non-www domain name, you will want to make sure that one will be redirected to the other one, thus avoiding duplicate content. Redirecting can also remove duplicate content that is produced by trailing slash. This can be done using the following ways.

Configure Redirecting in WordPress

Go to WordPress admin panel. Under Settings, click General. You will see WordPress Address(URL) and Site Address(URL), They are essentially the same.  Enter your preferred domain in the two text fields. And save your changes. I choose www version for my another website.

www vs non-www

Now whether you type www version or non-www version of your domain, you will be landed on your preferred domain.

Web Server 301 Redirect

If you have a virtual private server or dedicated server, you can implement 301 redirect in your web server. 301 redirect means permanent redirect. I will show you how to configure it in Nginx web server.

Open your Nginx virtual host file, on CentOS/Redhat server it’s usually /etc/nginx/conf.d/ On Debian/Ubuntu Server, it’s /etc/nginx/sites-available/yourdomain

sudo vi /etc/nginx/conf.d/


sudo vi /etc/nginx/sites-available/yourdomain

If you would like to redirect to, then change the virtual host file as follows:

server {
           listen 80;
           return 301 $scheme://$request_uri;
server {
          listen 80;
          root /usr/share/nginx/html;
          index index.php;
          client_body_buffer_size 8k;
          client_max_body_size 2m;
location / {
         try_files $uri $uri/ /index.php?$query_string;

As you can see, you need to create a new server block for the domain that will be redirected. Save your file and reload Nginx configuration.

sudo systemctl reload nginx


sudo /etc/init.d/nginx reload

Set Your Preferred Domain in Google Search Console

You should also set your preferred domain in Google Search Console to tell Google only index the www version or non-www version of your site. The preferred domain is also referred to as the canonical domain. You can check your Google index by typing the following in Google search box.

Let’s say your preferred domain is,  first type this:

You should see how many web pages Google has indexed your site.

After that type the following, without www.

You should also see your indexed web pages with www domain. Your non-www domain should not be listed in the results. If you only see www-version of site, then you are good to go. If you see non-www version of your site, then you have a problem.


If you tell Google your preferred domain is, then when someone else link to your site, Google will interpret that as  And vice versa. So your backlink will not suffer.

I hope this article will clear your confusion of www vs non-www.

Rate this tutorial
[Total: 2 Average: 3]

Leave a Reply

Your email address will not be published. Required fields are marked *