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>

<VirtualHost *:80>
ServerName domain2.com
ServerAlias www.domain2.com
DocumentRoot "C:\apache\htdocs\domain2"
</VirtualHost>
link|improve this question
Is this all what you have in your server config with regard to virtual hosts? – Khaled Jan 10 at 8:45
Yes, everything else is not changed – Qmal Jan 10 at 8:47
Do you have a single or multiple IPs assigned to these two names? – Khaled Jan 10 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 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 at 8:56
show 1 more comment
feedback

1 Answer

You should add

NameVirtualHost *:80

line above the VirtualHost sections

Save httpd.conf and restart httpd

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.