Apache for Mac OS X:: Do I need to setup another host for www?
Surfing the web and watching TV has made you think the “www” in front of a web address is a given. True, most sites do not require you to type “www”. The truth is “http://www.example.com” and “http://example.com” are two different URLs hosted by two different hosts. Most server admins set it so that “example.com” is forwarded to “www.example.com” making “www” the default server.
If you set up everything using the ServerAdmin GUI, creating two hosts “www.example.com” and “example.com” pointing to the same web directory is easy. But it becomes a pain afterwards when you need to tweak settings – you have to do the same thing twice. Also, ServerAdmin writes so much crap to the config files, having redundant info makes server reloads slow. The solution is to use some finesse with your httpd config files.This post will tell you a little more about httpd.conf for Mac OS X.
So, in one of your conf files, you need to add just four lines:
Redirect / http://www.example.com