Is there a way to create a wildcard domain in the Windows hosts file.
I tried this
xxx.xxx.xxx.xxx *.somedomain.com
This does not work, is there maybe some other syntax I should use?
I am working on Windows 7
|
|
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.
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! |
|||||
|
|
It's another syntax: xxx.xxx.xxx.xxx somedomain.com Some examples to explain it:
You block/lead all second (third,fourth...) level urls with the top(second,third...) level url in the hosts file. |
|||||||||
|
|
I did a test on Windows 7 hosts file. I removed all subdomains of an advertisement site, saved the hosts file, rebooted the PC (closing the browser and reopen it seems to be enough though) and revisited the news site (dutch news: nu.nl). The advertisements were NOT blocked. Then I did a test with *.domain.topdomain. This seems to work in MAC OS-10. But in Windows 7 the advertisements are not blocked at all. So it seems we need the long and windy version of hosts to do the job. |
|||
|
|
|
AngryHosts provides an easier way to support wildcard in hosts, it set up a local DNS to achieve this. It's actually a hosts enhancement and management software, you may like to give a try~ |
|||
|
|
|
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. |
|||
|
|
|
pDNS is a free portable windows hosts file replacement with wildcard and questionmark support. It acts as personal dns server (very similar to DNSmasq). |
|||||
|