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/yourdomain.com.conf. On Debian/Ubuntu Server, it’s /etc/nginx/sites-available/yourdomain

sudo vi /etc/nginx/conf.d/yourdomain.com.conf

or

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

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

server {
           listen 80;
           server_name yourdomain.com;
           return 301 $scheme://www.yourdomain.com$request_uri;
}
server {
          listen 80;
          server_name www.yourdomain.com;
          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

or

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 www.yourdomain.com,  first type this:

site:www.yourdomain.com

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

After that type the following, without www.

site:yourdomain.com

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.

Backlinking

If you tell Google your preferred domain is www.yourdomain.com, then when someone else link to your site asyourdomain.com, Google will interpret that as www.yourdomain.com.  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 *