Apache – hosts file and multiple sub-domains


For local testing (and learning), I wish to use x.com host name instead of localhost. I changed my Windows XP host file to this –       x.com

Now http://x.com/ works beautifully but http://www.x.com doesn't. 🙁

What changes should I make so that www.x.com, sub1.x.com, sub2.x.com etc.. all work on local. WordPressMU will lets users create sub-domains dynamically.

I am basically trying to setup WordPressMU locally. I'm using Apache/2.2.4, PHP/5.2.4, and MySQL5.

Please help!

Best Solution

You can also put all the host names for an IP address on the same line: 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 for DNS). This allows you to setup wildcard entries like *.x.com.