Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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)

Thanks.

share|improve this question

2 Answers 2

Apache:

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).

IIS:

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.
share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.