Eliminating Local Host File Entries

If you work with multiple sites configured in IIS you have most probably at some time had to edit your hosts file (c:\windows\system32\drivers\etc\hosts). For example a common scenario I’ve worked with many times

  • Create a site and give it some arbitrary binding in IIS e.g. mysite.local
  • Open the host file or use IIS Host Manager (http://iishosts.codeplex.com/) a free plugin that allows you to edit your host entries in IIS manager
  • Add your binding the list of host entries
  • Flush your DNS cache to make sure all DNS entries are updated

I’ve been working at Redweb doing this for some time but thanks to a comment made on Google+ by Bart De Meyer (https://plus.google.com/u/0/103218862903013258879/posts) he has lead me to the following site http://readme.localtest.me.

Essentially there is a mapped local binding for *.localtest.me which maps to your local loopback IP of 127.0.0.1. Therefore as long as in step one you set your binding to be SOMETHING.localtest.me (replacing the something in bold with whatever you wish to call your site) it will resolve to your local machine. This means for local development you no longer have to worry about the host file entries ever again and as a bonus it means all your site conform to the same local binding structure.

The one caveat to this approach is this works because the domain owner of localtest.me has pointed an A-Record to localhost. Therefore you are dependant on his ownership of this domain, we have purchased our own domain so we can manage this ourselves and not have to worry.

Many thanks again Bart

About ScottReed

I am an ASP.NET C# developer working in the south of England current for the south's top digital agency Redweb. I have worked for financial companies, CMS vendors, charities and web agencies tacking a variety of challenges. As part of my jobs and freelance I have done lots of work for high profile companies, big brands and government bodies and worked on some exciting large award winning builds. I love development and enjoy architectural design of software. ScottGu is my .NET hero and the Guru of all thing M$oft