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

I have a server at home that I plan to use to host two websites using Apache, I bought two domains and made them go to my server IP, but the problem is that it only works for one of them, if I enter domain1.com it goes to /domain1, if I enter domain2.com it still goes to /domain1.

This is my configs for them, I did this by reading some tutorials and such.. Can you please explain what did I do wrong here?

<VirtualHost *:80>
ServerName domain1.com
ServerAlias www.domain1.com
DocumentRoot "C:\apache\htdocs\domain1"

<VirtualHost *:80>
ServerName domain2.com
ServerAlias www.domain2.com
DocumentRoot "C:\apache\htdocs\domain2"
share|improve this question
Is this all what you have in your server config with regard to virtual hosts? –  Khaled Jan 10 '12 at 8:45
Yes, everything else is not changed –  Qmal Jan 10 '12 at 8:47
Do you have a single or multiple IPs assigned to these two names? –  Khaled Jan 10 '12 at 8:51
Don't understand this one. My server has 1 IP, so both domains are linked to it. Single I guess, but don't really understand the question. –  Qmal Jan 10 '12 at 8:53
Have a look at this page. It may help you. httpd.apache.org/docs/2.0/vhosts/examples.html –  Khaled Jan 10 '12 at 8:56

1 Answer 1

up vote 3 down vote accepted

You should add

NameVirtualHost *:80

line above the VirtualHost sections

Save httpd.conf and restart httpd

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.