I am hosting a couple of site on my apache:
- domain-x.com
- domain-y.com
- test.domain-y.com
Each site has its own file in sites-available. Domain-y serves to sites, one with domain-y.com
and the other with test.domain-y.com
.
domain-x:
<VirtualHost *:80>
ServerName domain-x.com
Redirect permanent / https://domain-x.com/
</VirtualHost>
<VirtualHost <ip>:443>
DocumentRoot /var/www/<folder>
ServerName domain-x.com
ServerAlias "domain-x.com" "www.domain-x.com"
</VirtualHost>
domain-y:
<VirtualHost *:80>
ServerName domain-y.com
Redirect permanent / https://domain-y.com/
</VirtualHost>
<VirtualHost <ip>:443>
DocumentRoot /var/www/<folder>
ServerName domain-y.com
ServerAlias "domain-y.com" "www.domain-y.com"
</VirtualHost>
test.domain-y.com
<VirtualHost *:80>
ServerName test.domain-y.com
Redirect permanent / https://test.domain-y.com/
</VirtualHost>
<VirtualHost <ip>:443>
DocumentRoot /var/www/<folder>
ServerName test.domain-y.com
ServerAlias "test.domain-y.com" "www.test.domain-y.com"
</VirtualHost>
This works fine but I would like to disable the test.domain-y.com if not needed and display a 404. If I remove the site using a2dissite and call the subdomain site "test.domain-y.com", the domain "domain-y.com" is shown instead without 404.
So I understood that I need a catch all, so I created a 00-catch.all.conf that holds these statements:
<VirtualHost *:80>
ServerName null
ServerAlias *
Redirect 404 /
</VirtualHost>
<VirtualHost *:8080>
ServerName null
ServerAlias *
Redirect 404 /
</VirtualHost>
<VirtualHost *:443>
ServerName null
ServerAlias *
Redirect 404 /
</VirtualHost>
But if I enable the catch all then still the subdomain site is available.
Any hint?
Thanks