How to redirect www to non-www URL using htaccess

redirect www to non www url 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 Reply

Your email address will not be published. Required fields are marked *