Working with subdomain on localhost

If you need to test sub domains on your development machine before deploying your web application, then you might be wondering how this can be done. Fortunately there’s an easy way to do this and all you have to do is add an entry in the hosts file for the subdomain.

Location of the hosts file : C:\Windows\System32\drivers\etc

Note that the hosts file does not have an extension and resides in the same location for Windows 7, Vista or XP.

You will need to open this hosts file in Notepad as an administrator, otherwise you wouldn’t be able to edit the file. Since all IP address starting with 127 belongs to localhost, you can therefore add a second entry in the hosts file for the subdomain that you want. An example is shown below:

Once the changes are saved, you will be able to browse to If you want to setup a website in IIS for that sub domain, then you will need to edit the bindings so that it listens to on port 80.

comments powered by Disqus