Skip to content

A simple tool to switch between host files and block/redirect websites for different purposes. Built for developers needing to test programs and for other users wanting to temporarily block or redirect websites (locally) for their own purposes such as to prevent distraction or other things.

Notifications You must be signed in to change notification settings

AdrianCurtin/HostsSwitcher

 
 

Repository files navigation

Hosts Switcher

This small tray icon utility takes care about your host files, so developer can easily switch between QA, production and local environment.

Web developers in big companies (such as myself) often struggles with different environments - local, QA, production, performance test environment, etc. To make things more difficult, we're usually taking care about multiple web sites. This simple tool helps you out to change hosts quickly - by overwriting your C:\Windows\System32\drivers\etc\hosts file (which is serving as first level dns proxy) by set of predefined hosts.

This version operates by creating and saving different host profiles which can be rapidly written to the windows hosts file. This prevents having multiple hosts files in the directory at a time and allows for easy manipulation of which sites are blocked (or rerouted). The XML document specifies a few parameters for each address:

Enabled: Identifies if the line is to be used at all

Local: Will use localhost instead of any specified Redirection

Www: Will add both the original domain (originaldomain.com) and with www. appended (www.originaldomain.com) so that the redirect will apply to both entered addresses.

Redirected: the IP address that the domain will be directed to

Address: The domain that will be redirected

This xml file is saved to your application data folder and can be Exported or Imported using the Export/Import profiles under the File menu.

Please note web browsers have dns cache on their own so once you change hosts; you have to either close and reopen your browser once you do the change or use some plugin - such as DNS flusher in Mozilla.

Hosts Switcher Screenshot

Using the Import Hosts tool (+++ icon in lower right) You can copy and paste in domains to be added, or whole hosts files for rapid entry. The Import tool also will accept lists of names separated by linebreaks (ex: google.com) or space/tab separated addressess and domain pairs (ex: 127.0.0.1 google.com). Comments denoted by # and following text will be ignored. If only a domain name is included in the import, the link will be imported into the current profile with a localhost redirect by default.

Hosts Import Tool

About

A simple tool to switch between host files and block/redirect websites for different purposes. Built for developers needing to test programs and for other users wanting to temporarily block or redirect websites (locally) for their own purposes such as to prevent distraction or other things.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%