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 am locally developing a website via MAMP and rather than messing with the changing all of my links and etc later on I opened up etc/hosts and added this line localhost so that my site thinks it has the domain name, this works great. However I can't access a part of my site within a subdomain etc routes to localhost. Is there any way to route localhost to yet still keep accessible?

UPDATE: I just found out that my subdomain is redirecting to my domain. I'm gonna guess that it is virtually impossible to prevent localhost from routing to some specific directory ex.

share|improve this question
That shouldn't happen; something else is screwed up. – womble Aug 27 '11 at 4:27
Your right, I just noticed that my subdomain is redirecting to my domain, please check the update to my post. Is there anything that can be done? – ThomasReggi Aug 27 '11 at 4:57
I'd say "probably not". Why would you be redirecting between subdomains anyway? – womble Aug 27 '11 at 5:40
up vote 0 down vote accepted

In windows, I think if "" is mapped to localhost, it is independent from You need to specify every single subdomain in the hosts file for it to work.

share|improve this answer

I just got done figuring out what the problem was. If you look into your private/var/log/apache2/error_log (or whatever your error log file may be) you'll notice that there's an error that says VirtualHost overlap on port XXXX.

To get away without overlapping (which will default to the first VirtualHost) specify a NameVirtualHost in your httpd.conf like this:

NameVirtualHost *:80

<VirtualHost *:80>
  DocumentRoot "/Users/Thomas/Sites/mysite"

<VirtualHost *:80>
  DocumentRoot "/Users/Thomas/Sites/subsite"

You may have already figured out how to do this, but I had a difficult time trying to find the answer myself so I might as well make it easier to find for other people.

share|improve this answer

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.