Apache .htaccess redirect www to non-www and non-www to www
Here are two examples of general rule for apache to redirect your urls to the prefered one, www to non-www or vicevesa.
www to non-www, also my prefered one:
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301]and non-www to www:
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]