Using wildcards in names in Windows hosts file

There is not. The hosts file isn't very clever, you have to list every subdomain individually (including www and no-www)

An answer to a very similar StackOverflow question worked well for me.

Wildcard Support on XP at hostsfile. Enjoy.

Basically, this program Acrylic works as a DNS proxy for your local machine. Just point your Local Area Connection to, then edit the AcrylicHosts.txt in a very similar manner to the regular hosts file -- only with wildcards!

Dnsmasq is what you need but it doesn't work quite well on Windows. So I wrote an alternative on Windows called DNSAgent.

You can use regular expression in rules. There is also some advanced features like customizing cache TTL, non-standard-port DNS server, compression pointer mutation, etc. Open sourced under MIT license.