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.


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

Open in new window

GuildOfDruidsAsked:
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?
0
 
ai_ja_naiCommented:
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)
0
 
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?
0
 
GuildOfDruidsAuthor Commented:
typooooo, my bad. I spelled domain name wrong. damn. Thanks alot
0
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.