How to redirect www URLs to non-www

In order to redirect all requests for www.yourdomain.com to yourdomain.com, you should set the appropriate rewrite rule. This can be done by adding the following lines at the beginning of the .htaccess file in your public_html folder:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]
From now on, when someone accesses http://www.yourdomain.com s/he will be redirected tohttp://yourdomain.com.
Using this method is safe because it should not create any redirection loops nor it should interfere with other rewrite rules.
Theme images by LonelySnailDesign. Powered by Blogger.