3

Well, I'm pretty new to this, so, I'm sorry if I'm making some stupid mistake but I've been trying to make my Apache Virtual Hosts work fine for different domains. I have one VPS with CentOS 6 and Apache 2 where I'm running 2 websites with diffent domain names; they were both working fine some days ago. But After I made some changes (i dont remember them) they're acting stupidly. The problem is that the both of the domains are pointing to the first document root in the vhosts file. This is my vhosts.conf

NameVirtualHost *:80

<VirtualHost *:80>
     ServerAdmin support@domain.me
     DocumentRoot /var/www/domainme
     ServerName domain.me
     ErrorLog /var/www/log/domainme.log
</VirtualHost>
<VirtualHost *:80>
     ServerAdmin support@domain.com
     DocumentRoot /var/www/domaincom
     ServerName domain.com
    ErrorLog /var/www/log/domaincom.log
</VirtualHost>

Everytime I try to access domain.com it gives me the index file of domain.me but if I put domain.com's configuration before the domain.me in vhosts file, and go to domain.me; it will give me the index of domain.com. I have two IP's for the VPS by the way. Thank for reading, hope that its not a big issue.

Raees Iqbal
  • 2,160
  • 1
  • 18
  • 15

1 Answers1

2

Try this one

Listen *:80
NameVirtualHost *:80
<VirtualHost *:80>
    ServerAdmin contact@domain.tld
    DocumentRoot /path/to/domain1/
    ServerName domain1.com
    ServerAlias domain1.com www.domain1.com
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin contact@domain.tld
    DocumentRoot /path/to/domain2/
    ServerName domain2.com
    ServerAlias domain2.com www.domain2.com
</VirtualHost>
Steel Brain
  • 4,321
  • 28
  • 38