How to remove www from your domain name
Because of the popularity of my article on .htaccess Redirects from May 2005 I get emails quite often asking questions on how to use .htaccess to remove the www from a domain, or how to redirect from no-www to www. Here is some background information and how to do it.
WWW is depreciated
WWW stands for World Wide Web, which is a term that is seldom used anymore. The use of www in a domain name is redundant and time consuming, browsers automatically prepend all URLs with the http:// protocol which connects to the HTTP server for serving a sites files. Why then is there a need to type www as well?
Most decent web servers will display the exact same files at http://domain.com and http://www.domain.com. This is the most common solution, however you may want to use only one or the other.
Redirecting from www to no-www at your domain
Using some simple .htaccess trickery it is easy to redirect anyone visiting your site with the www. to http://domain.com. Simply adding the following to the .htaccess file in your root folder:
RewriteEngine onOptions +FollowSymlinksRewriteCond %{HTTP_HOST} ^www\.DOMAIN.com [NC]RewriteRule ^(.*) http://DOMAIN.com/$1 [L,R=301]- Download this code: /code/want_no_www.txt
Redirecting from no-www to www at your domain
It is possible to do it the other way around as well, redirecting anyone visiting your site without the www. to http://www.domain.com:
RewriteEngine onOptions +FollowSymlinksRewriteCond %{HTTP_HOST} !^www\.DOMAIN.com [NC]RewriteRule ^(.*) http://www.DOMAIN.com/$1 [L,R=301]- Download this code: /code/want_www.txt
Which method to use
It really is up to yourself which you use. What you must make sure of is that visiting with or without the www still displays your site, and that visiting one doesn’t result in an error message.
In my opinion WWW is pretty much invisible these days, it is so common that everyone has become accustomed to seeing it. Thus, having your site redirect from the www to just http://domain.com I feel looks better, is shorter to communicate and works just as well! For example visiting http://www.thesidepath.com always redirects to the no-www option.
PS. This is an old and well discussed topic on the internet, these are my thoughts and opinions and are written here to help inform my visitors to the .htaccess Redirects topic on how to successfully go about removing or redirecting to or from the www in a domain name.