Remove WWW in URL through htaccess

I always want to have my website url remove the www in the address so I can have shorter address displayed in the address bar on a web browser and at the same time save keystrokes in typing a URL. Example, I have the website http://www.abc123.com I will just want to have http://abc123.com instead. Just insert the code below in your .htaccess file and you will be able to remove the obvious www in every website address.
RewriteEngine On 
RewriteCond %{HTTP_HOST} !^your-site.com$ [NC] 
RewriteRule ^(.*)$ http://your-site.com/$1 [L,R=301]

No comments:

Post a Comment