Although I know that this topic has been already discussed in some other threads where it is explained how to configure Virtualhosts in Apache. The thing is after looking for possible answers to my problem here, researching in Google and reading Apache official documentation I cannot have my problem solved.
Firstly, I had one WordPress installation running on Apache 2.4 installed in CentOS 7 and I set up the following Virtualhost:
<VirtualHost *:80> ServerName subdomain1.domain.com ServerAlias www.subdomain1.domain.com DocumentRoot /some/path/to/wordpress <Directory "/some/path/to/wordpress"> DirectoryIndex index.php Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all Require all granted </Directory> <Files ".ht*"> Require all denied </Files> ErrorLog "logs/subdomain1-error.log" CustomLog "logs/subdomain1-access.log" combined LogLevel warn </VirtualHost>
It worked fine but then I decided to add a Moodle installation (because the server doesn't have too much traffic) and then if I browse in Chrome subdomain1.domain.com or subdomain2.domain.com it doesn't matter, Chrome always goes to subdomain2.domain.com (Moodle website).
I tried in Chrome and Firefox with same results. The moodle Virtualhost is:
<VirtualHost *:80> ServerName subdomain2.domain.com ServerAlias www.subdomain2.domain.com DocumentRoot /some/path/to/moodle <Directory "/some/path/to/moodle"> DirectoryIndex index.php Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all Require all granted </Directory> <Files ".ht*"> Require all denied </Files> ErrorLog "logs/subdomain2-error.log" CustomLog "logs/subdomain2-access.log" combined LogLevel warn </VirtualHost>
Also, the Apache configuration file httpd.conf includes these VirtualHosts using the directive: IncludeOptional conf.d/*.conf
127.0.0.1 localhost 18.104.22.168 subdomain1.domain.com 22.214.171.124 subdomain2.domain.com
I cannot see any obvious error in my Apache Virtualhosts configuration files so I would appreciate if someone could give me a hint about what it is wrong and any possible error.
Thanks a lot.