hosts file and multiple sub-domains hosts file and multiple sub-domains apache apache

hosts file and multiple sub-domains


You can also put all the host names for an IP address on the same line:

127.0.0.1 x.com www.x.com sub1.x.com sub2.x.com

If you have a lot of sub-names, it would certainly be easier with a wildcard but unfortunately this is not supported with the hosts file.

Alternatively you could download the trial version of Simple DNS Plus which you can use to run a local DNS server on your XP machine (make sure to setup TCP/IP to use 127.0.0.1 for DNS). This allows you to setup wildcard entries like *.x.com.


You can repeat the same IP address several times to redirect multiple host names. You have to list the full host names though -- you can't list domain names or wildcards and expect all hosts in that domain to redirect to the IP address.

127.0.0.1 x.com127.0.0.1 www.x.com127.0.0.1 sub1.x.com127.0.0.1 sub2.x.com


You may try AngryHosts, with which you can add wildcard hosts rules.