Edit your hosts file

From Freephile Wiki
Jump to navigation Jump to search

First a little backgrounder: All websites have an address. I don't mean the domain name (example.com), I mean the IP (Internet Protocol) Address such as 10.10.3.1 The mapping of domain names to IP Addresses is something which is handled by the DNS system. DNS, or Domain Name Service is like the phone book for the Internet. Every time you "call" a website (eg. facebook.com), your computer asks DNS which IP address that website lives at. With the domain translated to IP, your request gets routed across the internetwork of computers so that a response comes back (usually in the form of some lolcat or selfie).

As a web developer, you invariably end up working on new versions of websites that are not publicly visible -- at least not at the 'official' address. Once the preparations are done and everything is fully baked, you have to switch on the new site. How do you get the "beta" site developed when all the links and images etc. have to look and feel exactly as if they were the real thing? The answer is the "hosts" file on your computer. Using the hosts file, you can tell your computer that example.com lives at any IP address you want, including the "localhost" address of 127.0.0.1

If you ever need to work on sites before they are live, you'll need to modify the hosts file on your computer. Instructions are a bit different depending on the Operating System you're using: a Linux computer, MacOSX, or Windows.