How to set multiple subdomains in the host file (DNS)?

Wildcards don't work in hosts files. You either have to write them all:

w.x.y.z example.com foo.example.com bar.example.com baz.example.com

or setup proper DNS


If you REALLY want this to work you should be using DNS as stated but if you're not in control of DNS and need to use the HOSTS file, you can use a DNS Proxy on your PC which allows wildcards in its own HOSTS file.

Example is in this thread, read down to the post about Acrilic DNS : https://stackoverflow.com/questions/138162/wildcards-in-a-hosts-file