Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to set up 2 virtual host entries in apache but I'm not sure how to accomplish what I want to do. I have two domain names, both pointing to the same IP Address. I need the DirectoryIndex to be different, which is pretty much the only difference in the entries. I have the following set up:

<VirtualHost *:80>

    ServerName firstdomain.com
    ServerAdmin email@example.com
    DocumentRoot "/srv/www"
    DirectoryIndex  /portals/site/index.html

</VirtualHost>

<VirtualHost *:80>

    ServerName seconddomain.com
    ServerAdmin email@example.com
    DocumentRoot "/srv/www"
    DirectoryIndex  /portals/site/index_fr.html

</VirtualHost>

Not sure what I need to do differently but the second entry doesn't work. The only real difference is I need the second domain to point to a different DirectoryIndex. If there is a better way to accomplish this, your help would be appreciated.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

You need to add NameVirtualHost *:80 somewhere before the VirtualHost sections in your configuration. Otherwise, your VirtualHost sections are treated as IP-based virtual hosts, and as you correctly have observed, the second entry is essentially getting ignored.

You may want to read up on name based virtual hosts.

share|improve this answer
add comment

Your Answer

 
discard

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.