I have an odd situation where I want to have the URLs app1.example.com, example.com and *.example.com all using a different virtual h
Wildcards can only be used in the ServerAlias rather than the ServerName. Something which had me stumped.
For your use case, the following should suffice
ServerAlias *.example.com
VirtualDocumentRoot /var/www/%1/
There is also more information at https://www.chris-shaw.com/blog/using-wildcards-in-virtual-hosts-on-apache