How To Set Up A WWW Or Non WWW Website Address Preference

setting website preferences

We all know that duplicate content within the same website is bad for your rankings. However, did you know that both your and versions could be indexed and therefore look like duplicate content?

This is what you can do to solve this problem.

Google Webmasters

1. Log into your webmasters account and click on the website that you wish to change.

2. Now click on the settings icon (a).

3. In the new windows select ‘site settings (b)

setting website preferences

4. You can then tick the version that you would prefer your site to be indexed as. Either the www version or the non www version.

In the diagram shown I have selected the version as the preferred one.

setting website preferences

 Wordpress Dashboard

Another thing to do is to set your preferred website version in your wordpress dashboard,

1. Click on ‘settings’ and then ‘general’

wordpress general settings

You can then enter your preferred website address in both the wordpress address (url) and the site address (url).

Htaccess Code

Changing the website address in your htaccess file is the best way to make sure that your site is seen as one only site rather than both the www and non www versions.

1. Log into your web hosting account and click on your file manager (I will assume that your hosting account uses cpanel)

2. Click on the website that you wish to change.

3. Locate your htaccess file and click edit.

4. Add the following code according to the version you want indexed.

(replace with the name of your domain)

Setting To WWW

# Redirect non-www urls to www
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.yoursite\.com
RewriteRule (.*)$1 [R=301,L]

Setting To Non WWW

# Redirect www urls to non-www
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.yoursite\.com [NC]
RewriteRule (.*)$1 [R=301,L]

Using this code will set up a 301 redirect so that when someone types in any version of your website it will always show the one that you have selected to show.

I recommend doing all of the 3 above to make sure that you are consistent.

How To Stop Your Htaccess Redirecting Any Sub Domain To Your Main Site

After implementing the above I found that I created another problem!

I have some sub domains of my main site:


Main site =

Sub domain =

When changing the htaccess code it caused my sub domain to automatically redirect so that it became a folder on my main site.


Before =

After =

This only happened to sub domains that I had not installed wordpress software on to.

This is how to sort this redirect out:

1.Go into your cpanel and open your sub domain in file manager.

2. Create an .htaccess file in your sub domain root folder by creating a new file and calling it .htaccess

3. Now edit that .htaccess file and add the following code:
RewriteEngine on
RewriteBase /

4. Save the file and you will have everything working fine again.

Leave a Reply

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