Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a way to create a wildcard domain in the Windows hosts file.

I tried this *

This does not work, is there maybe some other syntax I should use?

I am working on Windows 7

share|improve this question
You might want to edit your title, "wildcard" instead of "wildcart" – Millhouse Apr 28 '10 at 15:11
@Millhouse: Was bugging me too. ;) – Ƭᴇcʜιᴇ007 Apr 28 '10 at 15:17
i just answered a question on doing this with DNSmasq on ServerFault (not on windows, obviously, but on a router running DD-WRT/OpenWRT it's doable) – quack quixote Apr 28 '10 at 15:19
Thank you guys I will check this out. – Saif Bechan Apr 28 '10 at 15:44

6 Answers 6

up vote 27 down vote accepted

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

share|improve this answer

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!

share|improve this answer
Acrylic works great, but can confuse you if you are trying to access a machine with a dynamic IP address. I have machines connected to my home network, and I use a dynamic dns to set the ip for the domain name. I use Acrylic on my laptop and I was gone for a few days, in the mean time my ip changed, but Acrylic remembered it as being the old ip, and I couldn't access the site. But running the "Purge Acrylic Cache Data" program took care of the problem. – leeand00 Apr 13 '12 at 17:00

It's another syntax:

Some examples to explain it:

  • .com this line will block all outgoing dnsrequests ending with .com
  • will block all outgoing dnsrequests ending with
  • will lead all outgoing dnsrequests ending with to

You block/lead all second (third,fourth...) level urls with the top(second,third...) level url in the hosts file.

share|improve this answer
Given the last sentence, I assume is not blocked by the first line, but only when adding – Arjan Jul 21 '10 at 20:52
moonfern, I do not agree with your list. WILL NOT block all outgoing DNS requests ending with, all it will block is, not or or the like. – user43866 Jul 25 '10 at 5:32
That is definitely not the case on Windows, moonfern. – Owen Blacker May 27 '12 at 20:41

first, i agree with phoshi that its not possible to do what you want in the hosts-file of windows (neither on unix).

secondly, you have to get control over the result of a request to dns. one option is to use your own dns-resolving on your router (dnsmasq, dnscache+tinydns, bind, whatever, see quack's comment) and tweak it or to use a dns-resolver on windows which you can control as you want.

see here for a list of dns-resolvers, check for the "wildcard" column, maybe powerdns or maradns or posadis is something that fits your needs.

share|improve this answer

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.

share|improve this answer

pDNS is a free portable windows hosts file replacement with wildcard and questionmark support. It acts as personal dns server (very similar to DNSmasq).

share|improve this answer
You might want to disclose your association with the software in the answer as per the faq. It looks like a pretty cool piece of software (which i will try on a VM later) but we do have rules on promoting your own stuff. I also note its on mediafire and its an alpha version - what would be the licence of the final version, and do you intend to update the answer with newer versions? – Journeyman Geek Jul 5 '12 at 13:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.