apache NameVirtualHost overlaps

I have followed the namevirtualhost settings on apache's website. I dont know where i'm getting it wrong, as the first virtualhost overrides the other.

When I type www.domain1.com it's fine, but when I type www.domain2.com it shows me the content of domain1.

When I change the order, then the domain2 overrides/overlaps domain1.

Help please!! below is the virtual hosts config.

NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.domain1.com
ServerAlias domain1.com *.domain1.com
DocumentRoot /var/www/html/domain1
<VirtualHost *:80>
ServerName www.domain2.com
ServerAlias domain2.com *.domain2.com
DocumentRoot /var/www/html/domain2

Open in new window

Who is Participating?
caterham_wwwConnect With a Mentor Commented:
It looks like the ServerName/ServerAlias of your second vhost does not match for some reason. Could there be any additional non-visible character such as a special whitespace treated as character or something similar?
of course, you set aliases for the host namevirtualhost (which is *); and the order determines the priority; this means that domain1.com has higher priority over domain2.com
look here(http://httpd.apache.org/docs/1.3/vhosts/examples.html#purename)
GuildOfDruidsAuthor Commented:
Yes but want if I type domain1.com it should show me the content inside domain1 folder and same for domain2, how is that possible?
GuildOfDruidsAuthor Commented:
typooooo, my bad. I spelled domain name wrong. damn. Thanks alot
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.