This post is going to show about editing the hosts file. So first of all what is hosts file?
Hosts file is simple file which maps the host name and IP address. But this mapping is applicable for that machine only.
Location of this file can be vary based on the operating system. You can find full list of all OS with location of hosts files on each OS at this link.
You can edit the hosts file using any text editor but you will need administrator right for that.
You need to map ip address and host name as per below method.
You can use # to comment the line in hosts file.
Here is the real example of mapping the host name and ip address
So now after placing this in your hosts file, local.com will served form 127.0.0.1 means from local. It will load local site instead of actual site.
You can not specify port based IP address in hosts file. So below code will not work.
Note: You can not specify port based IP address in hosts file.
Once I had a great fun with this file. I have placed below code in hosts file of my friend’s machine.
So now whenever he types google.com in browser it will just load the local file of apache’s root. Really it was a great fun.
Have you done any fun like this with this file?
Avinash Zala is leading various projects which deals with the various technology involved with the web. A combination of perfect technical and management skills. Avinash would like to chat with you and convert your imagination into the working system. You can get in touch with him on Facebook and Twitter.
View all posts by: Avinash