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 hosting two separate sites with two separate domain names on the same server. Without using some kind of NAT forwarding, how can I set up my apache server so that, depending on which domain is used, the index.html file from a different directory is referenced?

share|improve this question

migrated from Jul 28 '10 at 1:47

This question came from our site for professional and enthusiast programmers.

Beware ISP's that will be blocking you from serving a website from your home. – Mitch Dempsey Jul 28 '10 at 0:00
Also beware dynamic IP addresses. See for one solution to the problem of changing home IP addresses. – dgw Jul 28 '10 at 0:06

This question will probably be migrated to Server Fault shortly, but the basic answer is that you need to set up a Virtual Host for each of the domain names. This page has a thorough description but a basic example would be:

<VirtualHost *>
   DocumentRoot /path/to/site1

<VirtualHost *>
   DocumentRoot /path/to/site2
share|improve this answer

Check out Apache's support for virtual named hosts, as described in the Apache 2.2 documentation. If both domains point to your home server's IP address in the DNS, you should be able to be up and running with a few changes to Apache's configuration file.

share|improve this answer

you will need a static ip address (or service that forwards to your ip address - pain in the back side as far as I'm concerned)...

but once you have that then you will need to configure virtual hosts...

If you have apache 2.2 you should have a 'extra' folder under 'conf' in your apache directory.

In this you will find httpd-vhost.conf which gives you the basic idea.

Finally in your main apache config file you will need to uncomment the line that includes teh vhost config...

# Virtual hosts
#Include conf/extra/httpd-vhosts.conf

and the line that loads the vhost module

#LoadModule vhost_alias_module modules/
share|improve this answer

Your Answer


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