301 Redirects for Apache

From non-www to www

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


From www to non-www: 
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.yoursite.com
RewriteRule (.*) http://nitish.info/$1 [R=301,L]