Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm new to configuring my Mac for localhost so this may be a dumb question. I want to set up a virtual host so that http://localhost/domain points to In my Apache configuration, I have localhost pointing to my Sites folder. That works correctly. I can browse to localhost/domain.

In my hosts file, I set up as

In my vhosts file, I set up the following entry:

DocumentRoot "/Users/username/Sites/domain/"

But when I uncomment this line in the Apache configuration:

Include /private/etc/apache2/extra/httpd-vhosts.conf

The browser adds "www" to the, which it then can't find. What am I doing wrong?

share|improve this question
up vote 0 down vote accepted

Just use ServerAlias.

   DocumentRoot /Users/username/Sites/domain/
share|improve this answer
I'm getting an error that the server cannot be found. I restarted Apache. – sehummel Nov 21 '12 at 17:55
Shouldn't there be a way to prevent it from adding the "www"? – sehummel Nov 21 '12 at 17:59
Try just putting in the IP address for localhost (, or just putting in localhost. Unless you're running a DNS server and have added the domain as an A record in a zone file, it won't resolve. – nojak Nov 21 '12 at 18:03
Oh, ok. Thanks. – sehummel Nov 21 '12 at 18:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.