Host File Modification for Web Design
When moving a client’s site from one host to another,whether it be the same or an updated version,any consciencous webmaster should take a few considerations.
- His priority should be to minimize the website downtime between DNS changes
- Editing a live website might cause temporary problems to visitors or logged users
Luckily,there’s a neat way to accomplish a seamless web host transfer by making changes to a simple file on our computer.
Since the DNS are still pointing to the old host,typing site’s the address in a web browser will take you to the old website/host which is not what we want so we will trick our computer into taking us to the new host.Doing so wil enable us work directly from there and view the changes we apply as if the site was live.
The Host file
Historically,and before the Internet as we know was accessible to everyone,the host file was used to map networks for ARPANET (it’s predecessor) before the invention of Domain Name Servers (DNS) in 1983.The file,still used in modern operating systems,retained it’s function which is to map a name like intelligentwebdesigner.com to a numerical address(example; 220.127.116.11) and will override any DNS information sent to your computer.
Permission to Edit The File
The file is owned by the Administrator.
On Windows open the Notepad using “Run as administrator”
Open the file from notepad,the locations are loosely different depending on the operating system;
Windows 95 – C:windows
Windows 98 – C:\windows
Windows Me – C:\windows
Windows 2000 – C:windows\system32\drivers\etc
Windows XP – C:\windows\system32\drivers\etc
Windows NT – C:\winnt\system32\drivers\etc
Windows Vista – C:\windows\system32\drivers\etc
Windows 7 – C:\windows\system32\drivers\etc
On Linux or Mac
On Mac or Linux, open a console and log as root,then run VIM,emacs or any text editor of your choice.
The file is located at;
So for example;
sudo vim /etc/hosts
Will launch VIM as super-user to edit the file.
Editing and Saving The Host File
Since the host file is a simple text file with a few lines,modifying it is also a simple task.
What you see inside is roughly the same in every operating system,something like;
127.0.0.1 localhost ::1 localhost
All you have to do is insert your domain name and the IP of the new Webhost right underneath this section.Usually I’ll add both version with www. and without it.
127.0.0.1 localhost ::1 localhost 18.104.22.168 intelligentwebdesigner.com 22.214.171.124 www.intelligentwebdesigner.com
Save the file and you’re done.Now typing the Domain name in a browser now take you to the new host.
Additional operating system information
Some operating systems might require a reboot after that and some Linux distribution might require you to confirm that the hosts file is actually used for the host lookup.
To do so go into;
and confirm that the following line is included;
That’s it don’t forget to remove the entries when you’re done and the DNS switch has occured.