How To Do 301 Redirect (WWW) Or Non-(WWW) & Why

To get the good presence on the search engine one have to follow its guidelines and work accordingly. Usually 301 WWW or Non-WWW redirect is done to remove the duplicacy of the url from search engine. You can open you site in two ways http://www.yoursite.com and http://yoursite.com . If you don’t do 301 redirect then two different mirrors are created on search engine one with WWW and other with non-WWW. This can make you to loose your search engine ranking and you cant track correctly the traffic of your site.

How to do 301 redirect on Apache server:-

1) 301 Non-WWW to WWW

Create a .htaccess file on your root and then copy the code below

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain\.com [NC]
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]

2) 301 WWW to Non-WWW

Create a .htaccess file on your root and then copy the code below

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.domain\.com [NC]
RewriteRule (.*) http://domain.com/$1 [R=301,L]

This will do the job for you and will solve your canonical problem

Bullten

A company providing web hosting solutions around globe...