In the hosts file how do I make it instead of redirecting to an IP address redirect to either a domain(example.com) or a URL on an IP address(127.0.0.1/example.html)? I tried typing it in but it doesn't work. I need to know how for Windows and Linux. How can I do it without a program or DNS?
Asked
Active
Viewed 8,559 times
1 Answers
12
The hosts file is called hosts for a reason, it is about exactly that, hosts. You can redirect a hostname to a different IP, but not a specific location at that ip. What you are trying to do is not supported, because you aren't directing a host to an IP, you are directing to an address.
Single Hostname:
1.2.3.4.5.6 example.com # redirects example to example ip
Double Hostnames:
1.2.3.4.5.6 example.com example.net # redirects examples to example ip