Using wildcards in names in Windows hosts file

Solution 1:

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

Solution 2:

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

http://mayakron.altervista.org/support/browse.php?path=Acrylic&name=UserManual

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 127.0.0.1, then edit the AcrylicHosts.txt in a very similar manner to the regular hosts file -- only with wildcards!

Solution 3:

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.