How to redirect www to non-www URL using htaccess

To redirect all www traffic to non-www URL – you need to add the following lines in .htaccess file:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www.example.com [NC]

RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

Replace example.com with your own domain name.

Leave a Comment