tags: #apache #apache2 #virtual #hosts #virtual-hosts #virtualhosts This [page at digitalocean](https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-20-04) This [stackoverflow question](https://stackoverflow.com/questions/31504003/apache-virtual-hosts-not-working-as-expected) contains something important that *isn't obvious* and would take a lot of doc-diving to find. The [TL;DR]() is that **apache2 uses the **`ServerName`** directive to distinguish virtual hosts, not the [FQDN]() at the top.** If you have some virtual hosts whose config looks like: ```plaintext ... ServerName myserver1 ``` but **you have at least one config that looks like:** ```plaintext ... ServerName server2 ``` then **the non-wildcard config takes precedence over all the wildcard hosts**. So for every virtual host, apache2 stops with the first `` that matches the incoming server address. So e.g. if in your hosts you have ``` 127.0.0.1 myserver1 server2 ``` then the `` will match for anything local. Thus you must make sure that the top line of **every** config is of the form ``` ``` as **even a single config that is not **`*:80`** will screw things up**.