Htaccess: How to redirect URL from www to non-www?

Posted by Damodar Bashyal on February 28, 2012

 

This is the universal code for redirection. First of all lets redirect from www to non-www with our .htaccess file.

#Use this for non-ssl URL redirection
<IfModule mod_rewrite.c>
    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
</IfModule>

More»

QR Code: Htaccess: How to redirect URL from www to non-www?