Blogging & SEOTips & Tricks

Canonical URL: How To Set Preffered Domain www or non www

Canonical URL, www or not?

Many bloggers/webmasters have known about this canonical URL issues, canonical pages and canonical tag pagination, but there are some who don’t know or maybe wondering what is preferred domain, how to set this up and what is the advantage of using WWW prefix or without it. I was wondering what I want to write in this blog about SEO for the first time. So I decided to talk about preferred domain or canonical URL for homepage. What to do if we change previous canonical URL. Well, I don’t know if there is advantage using WWW prefix or without it. But the problem is when you want to change your previous preferred domain into WWW or without WWW and you need to make standard URL to make sure you don’t get penalized because of duplicated content. Remember that the WWW and the non WWW version of a site is a different URL for search engine. As a proof their both statistics not exactly the same. Now If you only change it through your wordpress setting, many visitors from the search engine will find 404 page unless you redirecting it using 301 server side. So, you need to set this immediately with simple step. I’ll explain after this to redirect using .htaccess file at the bottom of this post.

When the first time after installing wordpress, you will probably go to Dashboard==>Profile then to Setting==>General. In this page, you will find whether to set your wordpress installation directory and URL using WWW or no. Simply choose what URL you prefer to be crawled by the search engine. There is a good SEO plug-in which can set canonical URL for post or page, it will add an attribute rel=”canonical” so the search engine know this canonical URL is important and higher priority among other link. Even some great themes have a built in feature about this. But the problem doesn’t stop here in case somehow you want to change your preferred domain/canonical URL for your homepage from to, but of course you do not want to loose all the statistic data, indexed back-links of your previous preferred domain and search result for your site keep running smoothly.

How to Setting Up?

Now, if you have a Google account, simply go to Webmaster Tools in order to set this up. So the search engine will synchronizing your statistic data, backlinks, and the search results and automatically detecting and redirecting your previous preferred domain into the new one. You have to verify your site ownership first by methods given. I prefer html method, just upload the downloaded html file to your home directory, click the link and you all set and verified. If you haven’t verifying your ownership before,you have to do this verification process twice. One for your and another for After that you now can set your preferred domain.

To specify your preferred domain:
1. On the Webmaster Tools Home page, click the site you want.
2. Under Site configuration, click Settings.

3. In the Preferred domain section, select the option you want.Then you will see this option, simply choose your preferred domain setting.

4. Save your setting, and you will receive a message in your dashboard that your preferred domain has been updated.This process usually only take about 5 minutes or less.

Now your site is done. All the detected backlinks, search results and other previous advantage you have gained will still remain and synchronized. So when someone accessing your previous canonical homepage URL for example, will be automatically detected and redirected to a new preferred domain

Other Search Engine?

That’s only for Google, what about other search engine? Let’s get done all by redirecting to the URL you want using .htaccess file. Open your .htaccess file in your root directory. You need to activate the directive like mod_rewrite engine in your apache/nginx server to make this work. Note that most of hosting provider have set this by default and they using rewrite module for apache too, so you just need to add this couple line to your .htaccess by opening it through your CPanel =>File manager ==> show dot file.

If you want www as your standard canonical for your URL then add this:

 RewriteEngine On
 RewriteBase /
 RewriteCond %{HTTP_HOST} !^www. [NC]
 RewriteCond %{HTTP_HOST} ^([^.]+.[a-z]{2,6})$ [NC]
 RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]

But if you want your standard canonical URL using without www then add this line:

 RewriteEngine On
 RewriteBase /
 RewriteCond %{HTTP_HOST} !^yourdomain.tld$ [NC]
 RewriteRule ^(.*)$ http://yourdomain.tld/$1 [R=301,L]

In this case you need to add your domain name and its extension eg. .COM or .NET or .ORG and other top level domain name of your own. So if your site is the line would be:

 RewriteEngine On
 RewriteBase /
 RewriteCond %{HTTP_HOST} !^$ [NC]
 RewriteRule ^(.*)$$1 [R=301,L

If something goes wrong, perhaps the rewrite engine was allready on so you just have to remove the first two line of all code above which is RewriteEngine and RewriteBase. After that save the file. That’s it you’re all set up!

Show More

Muhammad Azam

Don't think about what can happen in a month. Don't think what can happen on a year. Just focus on the 24 hours in front of you and do what you can to get closer to where you want to be.

Related Articles

One Comment

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top button

Adblock Detected!

If you enjoy our contents, please support our site by disabling your ad blocker or whitelisting us. We use ads to keep our content happy and free.