Question:
How to change Hosts file to redirect page not found to URL?
?
2018-07-02 12:07:43 UTC
So I've changed my Windows hosts file to block a number of sites that waste my time.

127.0.0.1 OffendingSite.com

This gives me an ugly page not found error, of course. Is there a way I can redirect to a specific URL (not IP)? I would love to redirect either to a local HTML page or to a time management page I use.

Thanks!!
Three answers:
VP
2018-07-04 16:25:20 UTC
The entire purpose of the HOSTS file is to map URLs to IPs -- not other URLs.
NerdyKid1101
2018-07-02 16:11:22 UTC
You CAN actually reroute sites. If you type in something like



154.36.80.12 www.google.com



Then whenever someone types google.com in the bar, it will go to whatever domain owns 154.36.80.12 (random numbers I used, no idea where they point haha) Makes great for pranks! Someone tries to go to facebook and opens up porn hub xD all you need to do is google a site's IP address and boom, the "domain name" someone types into the bar will go to whatever IP is associated with it in the file.
Chris
2018-07-02 12:39:23 UTC
AFAIK the purpose of the hosts file is to skip domain name resolution, which means you can only state IP address, not other hosts.

The only way to redirect to a web page is to run a web server on your computer. To do that you can install Apache, then edit its index.html file however you like. And if you put in a redirect or



you can redirect from there to any URL you like.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...