Sean Sperte

Removing “www” From a Domain

25 March 2007

Here’s what I do to remove “www” from my domain. I put this code in my .htaccess file:

  1. RewriteEngine On
  2. #Handle removal of “www”
  3. RewriteCond %{HTTP_HOST} ^www.YOURDOMAIN.com(.*)$ [NC]
  4. RewriteRule ^(.*)$ http://YOURDOMAIN.com/$1 [R=301,L]

A couple quick notes about this method if you want to use it as your own:

  1. In order to see/edit .htaccess, you may have to show “invisible” files in your FTP application.
  2. This only works on servers running Apache.

For more information, and a technical explanation of what each line does, read John Gruber’s post (and subsequent opinion of why one would want to do this) from May 2006.