301 Redirect With .htaccess
301 redirect through .htaccess file is the safest and most efficient method of permanently redirectly your web pages or directories or even your whole site.
One of the main reasons to put in a 301 redirect on your site is to redirect the non-www part of your site to the www part. In theory yourdomain.com and www .yourdomain.com are completely different sites - which means two different sites in the search engines. Some people will link to you with and without the “www” in your domain name and that is how the search engines will index you.
Now, again in theory, if you have 2 sites with exactly the same content indexed, you will likely have a duplicate filter assigned to your site. Which means you lose rankings and get in lots of trouble in trying to optimize your site.
Of the 3 major search engines, Google has real difficulty in sorting this problem out. So one of the safest things you can do is an overall 301 redirect of your whole site from non-www to www - this will mean once implemented, that if you type in yourdomain.com your browser will redirect this to your site with www in front of it.
How to implement a 301 redirect:
You need to edit your .htaccess file - so hopefully you have a unix server and access to it - either by cpanel directly or through simple ftp. If you already have an .htaccess file on your server, save it before you edit it.
The .htaccess file we will work with is in your root directory. Just ensure you have the following code within it:
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
And don’t forget to change the domain.com to your own domain. Otherwise you will find the 301 redirect redirecting your site to www .domain.com !
Hope that is useful - any other redirect queries please post here.


