1

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?

6

1 Answer 1

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
1
  • +1, great first answer. I don't see many new users start off this well.
    – bwDraco
    Nov 3, 2014 at 2:20

Not the answer you're looking for? Browse other questions tagged .