Geek & Mild by Sean Sperte

Hello. Welcome to the weblog of Sean Sperte. This is an article originally posted on March 25, 2007. Read more →

Removing “www” From a Domain

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.


POWERED by FUSION

no-www.org and yes-www.org have some interesting points in the debate on whether or not to use www in Web addresses. I personally like to accept traffic on www, then silently redirect to the non-www version.

§  Jon Bourne · 03 April 2007

Thanks for this tip! This will be extremely useful.

§  Will · 22 July 2007
Commenting is not available in this channel entry.