.htaccess Remove “www” from URL
November 5, 2009 # 10:33 PM # Code # 5 CommentsHere is a quick and easy code you can use in your .htaccess file, located in the root directory of your website, to remove any world-wide web letters from your url. This will remove “www” from all your website’s pages as well as search engines, etc.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.mywebsite.com$ [NC]
RewriteRule ^(.*)$ http://mywebsite.com/$1 [R=301,L]
And vice-versa you can add “www” to your website’s url with the following .htaccess code:
RewriteEngine on
Options FollowSymlinks
Rewritecond %{HTTP_HOST} ^mywebsite.com [NC]
Rewriterule ^(.*)$ http://www.mywebsite.com/$1 [R=301,NC]
All I did here was switch the places of the url of with “www” and the url without “www” in the code.
Just replace “mywebsite.com” with your website’s domain name.
Popularity: 2% [?]

Subscribe RSS
Comment RSS







Its very informative and interesting article.all the points are very useful. Simple but very effective writing. Thanks for sharing such a nice post.
I like the layout of your blog and Im going to do the same for mine. Do you have any tips? Please PM ME.
This is my first time i visit here. I found so many entertaining stuff in your blog, especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the leisure here! Keep up the excellent work.
This is a really good read for me. Must admit that you are one of the coolest bloggers I ever saw. Thanks for posting this informative article.
Useful article can i translate into French for my sites readers? Thanks