The common www part of web server addresses has annoyed me for a long time. It's unnecessary, ugly, and annoying to pronounce. There is even a site, no-www, that is dedicated to the effort of eliminating the www wart on web addresses.
dbaker today pointed me to an easy way to eliminate the www using Apache. Instead of using the cumbersome mod_rewrite as suggested on the no-www site, do something like this:
<VirtualHost *> ServerName www.example.com Redirect permanent / http://example.com/ </VirtualHost>
Then, remove the ServerName www.example.com line from the real server configuration section. This assumes that you are using NameVirtualHost, which isn't the default but probably should be.
This configuration quietly redirects any URL with www to the corresponding URL without. This improves the way your URL looks, improves search engine efficiency, and promotes world peace. Well, maybe not that last thing.
<VirtualHost *:80>
ServerAdmin nugget@slacker.com
ServerName www.slacker.com
ServerAlias ww.slacker.com
ServerAlias members.slacker.com
RedirectMatch permanent /(.*) http://slacker.com/$1
</VirtualHost>
2005-04-20T16:45:36Z