5 ways to edit the Hosts file like changing the name of sites and redirecting them

The Windows Hosts file allows you to define which domain names (websites) specific IP addresses are linked to.
For some it may not be easy to understand this concept of "name resolution" so a brief explanation is worthwhile.
Each website is inside a computer reachable from an IP address.
To navigate on a site, however, it was not convenient to write an IP address like 192.168.21.34, because it would have been difficult to remember.
So an association was created between these numeric addresses and a word, like pippo.com, called domain .
DNS servers are those computers located around the world in which all the associations of billions of sites are present and make sure that, by opening the browser, just write google.com to open Google or facebook.com to open Facebook.
DNS is the central addressing system and is a network parameter that I have already talked about (for example setting DNS with OpenDNS or SecureDNS allows you to filter dangerous sites).
The same thing happens in the Windows hosts file, locally and only for that computer and it takes precedence over DNS .
You can then do some tricks using the hosts file such as changing a site address, blocking browsing on some web pages locally, redirecting websites, creating links to websites, creating your own local domains, and more.
To edit the Windows Hosts file you need to open the notepad or Notepad (or any other text editor such as Notepad ++), as an administrator.
Then click on the Start menu, type notepad in the search box, right click on the link and select " Run as administrator ".
Go to File> Open in the Notepad window and navigate through the Windows folders to the following destination: C: \ Windows \ System32 \ drivers \ etc and open the file called hosts .
If it does not show up, search for it instead from Windows Explorer and then, once found, right-click on it, select Open with and choose notepad.
Since it is a hidden file, open a folder, go to Tools -> Folder Options, go to the View tab and select the " Show hidden files and folders " option.
Any changes made to the hosts file take effect immediately after saving the file so there is no need to reboot the system.
If you add multiple entries to the hosts file, make sure that each is on its own line and that there is no pound sign in front of it (otherwise they have no effect).
To make the space long, you must press the Tab key.
If you have installed programs like Spybot, you can see many lines already added starting with 127.0.0.1; those are all dangerous sites that are blocked for local security.
1) To block a website, just add a line similar to the following at the end of the hosts file:
127.0.0.1 example.com
127.0.0.1 is the IP address of the computer you are using therefore, if you associate the example.com domain with the IP address of this computer, it is obvious that it will not exist and the connection will immediately fail by blocking the loading of the site web.
There is no way to visit this site except by removing that line from the hosts file.
This use had already been explained in the past in the article "Prevent the browser from opening and browsing virus sites from the hosts file"
2) Create block lists of websites
As mentioned above, a program like Spybot (one of the best anti-spayware and malware programs) creates a list of domains to be blocked for security reasons.
There are also other lists such as the one on the winhelps site which seems to be the most used in the world.
3) Another trick that can come in handy is to redirect a website by changing its domain name .
With the same principle as before, it is possible to define a rule so that, if you type on the facebook.com browser, the Google site opens instead.
To do this you need to know the IP address of the target site which can be easily found using the Ping command in the command prompt.
From the Start menu, type cmd in the search box or in Run, open the prompt, write ping google.it and press Enter
The result will be a response from 173.194.35.184 which is the IP address to use in this example.
In the hosts file you can then write:
173.194.35.184 facebook.com
This line tells our computer to connect to the site at Google's IP address when visiting facebook.com.
4) With the hosts file, I always add a trivial line to the text file, you can also create shortcuts to get to a site .
For example it is possible to associate the "n" with Navigaweb.net or the g with Google.it.
In this way, only by typing it and pressing enter on the browser address bar, any browser, you navigate on Navigaweb.net.
It is possible to create links with multiple multiple letters, such as twit to get to Twitter.com or simply Facebook to get to Facebook.com (thus deleting the extension .com, .net, .it etc.).
To create shortcuts to websites, just add a line like:
173.194.35.184 g ( 173.194.35.184 is the IP of Google.it, found using the Ping command as in point 2).
5) Assign local domain names if using a local server.
Generally this is convenient in offices but also at home it can be useful to reach the router configuration panel.
So if, for example, the internal address of the router was 192.168.0.1, a line with the following can be added to the hosts file:
192.168.0.1 router
On the browser, just write the word router on the address bar to open the configuration panel.
To restore all the changes made, just delete the lines added to the end of the file and save it.
If you are in a bad position to edit the text file, you can edit the Hosts file with a program like Hostsman that allows you to add or delete lines from a more convenient configuration window.
Hostsman is a small free tool that allows you to edit the hosts file in a more intuitive way and that includes some lists of domains to be blocked for security reasons.

Leave Your Comment

Please enter your comment!
Please enter your name here