Remove www Subdomain

It seems that more and more people are moving away from the inclusion of www in their url. SitePoint recently wrote about the subject, and this past February Roger Johansson also wrote an article on the topic. Roger’s article was really more about making sure your site works with our without www (I couldn’t agree more). You wouldn’t get any more from me than you could get from taking a look at the articles I’ve referenced, therefore I’ll just skip to the good stuff. In general I feel that the inclusion of www is just a waste of address bar space. For this blog I have decided to throw it to the dogs. If I remember correctly, “Removing the Ws from URLs“, an article from 2002, was a big help for me on my path to www enlightenment.

Removing WWW through VirtualHost

<VirtualHost ipaddress>
ServerAdmin root@localhost
ServerAdmin webmaster@blueatlas.com
DocumentRoot /path/to/public_html/
ServerName jasonleveille.com
ErrorLog /path/to/logs/jasonleveille.com/error_log
TransferLog /path/to/logs/jasonleveille.com/access_log
</VirtualHost>

<VirtualHost ipaddress>
ServerName jasonleveille.com
ServerAlias www.jasonleveille.com
ServerAlias ww.jasonleveille.com
Redirect permanent / http://jasonleveille.com/
</VirtualHost>

Removing WWW through .htaccess

Perhaps you don’t have access to your VirtualHost block. Not a problem if your host/server/whatever allows you to override directives via .htaccess. This article on using .htaccess from Daring Fireball is a good reference regarding this topic.

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.yourdomain\.com$
RewriteRule (.*) http://yourdomain.com/$1 [R=Permanent]

Tags: ,

One Response to “Remove www Subdomain”

  1. leveille Says:

    More about www

Leave a Reply