Wednesday, March 12, 2014

Creating local domain with IIS

Recently, I gave a presentation that required webpages to be loaded from multiple domains:



Instead of registering multiple domains and publishing a couple of websites, I was able to achieve this locally through these simple three steps.

1) Add a new Web Site

Open Information Internet Services Manager (the easiest way to do this is to search for "IIS" from the Start menu) and expand your localhost entry in the tree on the left hand side exposing the "Sites" node. Right click on this and select "Add Web Site...".


2) Configuring the new Web Site


The most important thing to notice here is that the "Host name" must match the domain that you want to create locally. With the above configuration, I would expect to access this site by navigating to "www.mygoogle.com" in a browser.

3) Configure the HOSTS file

The last step is to force your computer to resolve requests to your domain to your local IIS instance and not resolve them through a DNS. This is achieved by adding a entry to the HOSTS file that points to your local machine. In Windows XP, Windows Vista, Windows 7 and Windows 8, the hosts file can be found here: c:\windows\system32\drivers\etc\HOSTS.


Any requests for "www.mygoogle.com" will now be resolved to the IP address of 127.0.0.1, which is the loopback address for you machine resulting in your local IIS serving the page:


No comments:

Post a Comment