I must test, on my local machine, an application that simulate cross-site scripting (HTML5 XMLHttpRequest Level 2) and so I need to configure IIS 7 or Apache 2 to manage multiple domain on the same IP (localhost).

How can do that with IIS or Apache?

(I'd like to know the solution with both the server)


2 Answers 2



As RedGrittyBrick says, check the Apache docs for some simple examples. Make sure you get the right version of the documentation - I don't think there are significant differences between the vhost configuration in v2.0.x and v2.2.x but just in case make sure you look in the right place: 2.0.x here and 2.2.x here.

Most Linux distributions break the configuration into multiple files in directories like "sites-available/-enabled" by default in their standard Apache packages - I don't know if common Windows builds will do the same (I assume the IIS mention means that you are using Windows rather than having a choice of OSs) so it would be worth adding to your question which Apache build you are using (the official Windows build, or one of the "WAMP" packages like this one, and so on) so people with experience of that package know to respond (or which Linux/BSD/other setup you have, if you are using Apache that way).


It depends which Windows variant you are using. To respond to different domain names with different content you need one of the server distributions as you need to setup one "site" for each in the IIS configuration and desktop installs only allow one. You can serve many names with the same content on all versions of IIS but I assume this is not what you want (as this is the default behaviour anyway).

If you have an appropriate Windows+IIS variant:

  1. In the IIS Manager, expand the node for your machine then the "sites" node. You should currently have one node under there called "default web site".
  2. Right-click the "sites" node, select "add web site" and follow the dialogues. You probably want to leave the IP address selection as "all available". "Site name" is the name that will appear in the IIS configuration, "host name" is the domain name (you can add further names later, see step 3.
  3. If you want the new site setup to respond to several names, for instance example.com, www.example.com, somethingelse.example.com and www.anotherexample.net, add one of the names in step two then when done click the new node in the IIS Manager and select "bindings" on the right-hand side. From here you can add the extra (sub-)domains. Unless you disable or reconfigure it, all names not listed for other sites will be served by the content and code pointed to by the "default web site" site.

For Apache, read the Virtualhosts documentation

At the client end (which could be the same computer), the simplest solution is to add entries in %Windows%/System32/drivers/etc/hosts.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .