Wednesday, January 2, 2013

A simple convention when hosting multiple sites locally

 

Firstly, A very Happy New Year 2013.

I wanted to share a sort of a neat trick/convention which I use to make my life easier when I am hosting multiple sites locally.

Suppose you are working on multiple web applications on the same desktop/laptop. Apart from using the built in Visual Studio Web Development Server, you would typically host your application on your local IIS as well, lets say for easier automated testing on your system.

Suppose you are working on two web applications which are hosted on the domains, earlyadopter.in and imadeitcount.com. Now you want to host these locally on your IIS as well. The typical approach would be to add an application to your IIS so that you may access these sites running locally through your browser by the following urls:

http://localhost/earlyadopter/

http://localhost/imadeitcount/

There are cases I have encountered where this has made life difficult. For example, if you are paring your url, you would have to do it differently for your localhost and for your actual production site.

What I do nowadays in these cases is that I modify the hosts file such that the following domains point to 127.0.0.1

http://earlyadopter.local

http://imadeitcount.local

Now, I can have as many local web applications without worrying about localhost.

What do you think? I think there may be better solutions out there, so if you know, please do leave a comment. I am also not sure how this would apply to LAMP stack solutions, so again, please do leave a comment if you have any insights on that end.

Cheers