.htaccess for SEO

I got a few requests on how to use the 301 redirect for the .htaccess file in order to do it search optimization friendly.

the below code , put into a .htaccess file in the root directory in an apache system would redirect a NON-WWW to WWW domain.

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

This would move yourdomain.com to www.yourdomain.com

This allows you to combine ‘pagerank’ so if someone linked to your non-www the pagerank should transfer over to the www… and translate into better rankings…. I stress the word ‘should’ :)