How to 301 redirect from www domain to non www domain using htaccess

Enable mod_rewrite module in apache.

Setting the “RewriteBase /”, sets the base of the URL to “/”

Replace example.com with your website domain name.



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

Author: ganeshhs

11 years of overall experience in the Internet industry with specialization in internet application development and deployment Proven experience in building, leading and managing high performance, cross functional software engineering teams Hands on experience in CodeIgniter, Zend Framework, PHP, JS, Jquery, MySQL, CSS, HTML, ElasticSearch, Redis, Redis, AWS, Unix.

Leave a Reply

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