Wildcards in a Windows hosts file


I want to setup my local development machine so that any requests for *.local are redirected to localhost. The idea is that as I develop multiple sites, I can just add vhosts to Apache called site1.local, site2.local etc, and have them all resolve to localhost, while Apache serves a different site accordingly.

I am on Windows XP.

I tried adding       *.local

to my c:\windows\system32\drivers\etc\hosts file, also tried:       .local

Neither of which seem to work.

I know I can set them up on different port numbers, but that is a pain since it is hard to remember which port is which.

I don't want to have to setup a local DNS server or anything hard, any suggestions?


To add to the great suggestions already here, XIP.IO is a fantastic wildcard DNS server that's publicly available.

      myproject.  -- resolves to -->
  other.project.  -- resolves to -->
   other.machine.  -- resolves to -->

(The ability to specify non-loopback addresses is fantastic for testing sites on iOS devices where you cannot access a hosts file.)

If you combine this with some of the Apache configuration mentioned in other answers, you can potentially add VirtualHosts with zero setup.

I made this simple tool to take the place of hosts. Regular expressions are supported. https://github.com/stackia/DNSAgent

A sample configuration:

        "Pattern": "^.*$",
        "NameServer": ""
        "Pattern": "^(.*\\.googlevideo\\.com)|((.*\\.)?(youtube|ytimg)\\.com)$",
        "Address": ""
        "Pattern": "^.*\\.cn$",
        "NameServer": ""
        "Pattern": "baidu.com$",
        "Address": ""
By : Stackia

You can use echoipdns for this (https://github.com/zapty/echoipdns).

By running echoipdns local all requests for .local subdomains are redirected to, so any domain with xyz.local etc will resolve to You can use any other suffix also just replace local with name you want.

Echoipdns is even more powerful, when you want to use your url from other machines in network you can still use it with zero configuration.

For e.g. If your machine ip address is you could now use a domain name xyz.192-168-1-100.local which will always resolve to This magic is done by the echoipdns by looking at the ip address in the second part of the domain name and returning the same ip address on DNS query. You will have to run the echoipdns on the machine from which you want to access the remote system.

echoipdns also can be setup as a standalone DNS proxy, so by just point to this DNS, you can now use all the above benefits without running a special command every time, and you can even use it from mobile devices.

So essentially this simplifies the wildcard domain based DNS development for local as well as team environment.

echoipdns works on Mac, Linux and Windows.

NOTE: I am author for echoipdns.

By : arva

This video can help you solving your question :)
By: admin