Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 have a domain which points to my IP address, now I want to do the following: if I access the server locally (localhost / I want it to server the pages from default DocumentRoot. If I access the server using the domain name, it servers files from other directory.

I edited httpd.conf adding following lines:

<VirtualHost *:80>
   ServerAdmin webmaster@localhost
   DocumentRoot "C:/Xampp/htdocs/mydomain"

unfortunately, it doesn't work as expected - it serves files from "C:/Xampp/htdocs/mydomain" even if I access the server via localhost.

How do I fix it?

share|improve this question
up vote 2 down vote accepted

Here is what you want:

Now when a request arrives, the server will first check if it is using an IP address that matches the NameVirtualHost. If it is, then it will look at each section with a matching IP address and try to find one where the ServerName or ServerAlias matches the requested hostname. If it finds one, then it uses the configuration for that server. If no matching virtual host is found, then the first listed virtual host that matches the IP address will be used.

As a consequence, the first listed virtual host is the default virtual host. The DocumentRoot from the main server will never be used when an IP address matches the NameVirtualHost directive. If you would like to have a special configuration for requests that do not match any particular virtual host, simply put that configuration in a container and list it first in the configuration file.

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.