I have Apache2 server running on Debian 9. And I have 2 virtualhost configs in /etc/apache2/sites-enabled/
folder.
First:
Options FollowSymLinks
<Directory "/srv/">
Options FollowSymLinks ExecCGI
Require all granted
</Directory>
<Directory "/srv">
Options FollowSymlinks ExecCGI
Require all granted
</Directory>
<VirtualHost *:80>
ServerName domain.sk
ServerAlias dev.domain.sk
DocumentRoot /srv/domain.sk/!www
<Directory /srv/domain.sk/!www>
Options Indexes FollowSymlinks ExecCGI
AllowOverride All
</Directory>
</VirtualHost>
Second:
Options FollowSymLinks
<Directory "/home/test/">
Options FollowSymLinks ExecCGI
Require all granted
</Directory>
<VirtualHost *:80>
ServerName domain.sk
ServerAlias test.dev.domain.sk
DocumentRoot /home/test/domain.sk/!www
<Directory /home/test/domain.sk/!www>
Options Indexes FollowSymlinks ExecCGI
AllowOverride All
</Directory>
</VirtualHost>
Problem is that if I go to dev.domain.sk
it is ok, but if I go to test.dev.domain.sk
it will show content of dev.domain.sk
and not content of test.dev.domain.sk
. If I disable first virtualhost config then I see content of test.dev.domain.sk
, so it looks like dev.domain.sk
"override" that test.dev.domain.sk
, how can I solve it?
The problem is that you are using the
ServerName
directive twice with the same name.ServerName
should be unique to each virtual host. You don't needServerAlias
in your example. Here is an example of what I'm talking about: