@recursional
It depends on your web server.
…
Apache uses the first VirtualHost configuration it finds, after sorting numerically then alphabetically.
For example, if you have three VirtualHost configurations:
adomain.com.conf
mydomain.com.conf
randomdomain.com.conf
Apache will use adomain.com.conf
as the default go-to when a request could not be otherwise sent to an actual domain on the server.
If, for example, you had a more mixed naming system such as:
000-domain.com.conf
adomain.com.conf
mydomain.com.conf
randomdomain.com.conf
Instead of adomain.com.conf
, Apache will use 000-domain.com.conf
since it’s numbered.
…
NGINX uses a far better, user-configurable method. Add default_server
to one (and only one) of your server blocks and it’s now the default.
For example (covering both IPv4 and IPv6):
server {
listen 80 default_server;
listen [::]:80 default_server;
root /path/to/home;
location / {
...
...
...
}
}
…
So to fix this on Apache or NGINX, you’d simply create a new VirtualHost or Server Block and make sure it’s numbered on Apache, or that it has default_server
defined for NGINX.