How to perform redirection from www to non-www version of the domain or vice versa

Performing redirection fom non www to www or essential is a essential for SEO of a particular site because most of the search engines treat both www and non-www version differently and hence regard a single page as duplicate of other.

Search engines than put penalty on  duplicate content  in spite of the fact that your article is original and genuine.

This can easily be avoided by using .htaccess file in the root of your Website.

NOTE: This method is applicable only to those servers which allow mod rewrite in Apache(Linux) or IIS(Windows). Please confirm with your host.

Add following lines to redirect all www request to non-www version of your domain

RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]

Add following lines to redirect all www request to non-www version of your domain

RewriteCond %{HTTP_HOST} ^example.com [nc]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

In above two modification we use 301 redirect which means that a given page is permanently moved from this location thus telling search engines not to take this page as duplicate copy of other.