Q:

Why doesn't my HOSTS file redirect DNS in Windows 7?

I've modified the HOSTS file on my Windows 7 machine in exactly the same manner as I have in the past on my Vista and XP machines; however it has had no effect.
How do you redirect URLs in Windows 7 or enable the HOSTS file so that it acts as it did in the previous versions of Windows?

A:

For Windows 7,

Open Notepad in Run as Administrator mode.
Now you can see these lines...
# localhost name resolution is handled within DNS itself.
#    127.0.0.1           localhost
#    ::1                 localhost

Add new line for your domain.
After the change it will be like this...
# localhost name resolution is handled within DNS itself.
#      127.0.0.1             localhost
#      ::1                   localhost
       10.40.0.9             xxx.com  
       10.40.0.10            yyy.com

Now save the hosts file. If it prompts to save it elsewhere then you forgot to open Notepad as administartor.
Go to Windows' command promt and run this command ipconfig /flushdns
Open your browser and try to browse xxx.com and yyy.com etc. Should work fine.

Note to remove '#' sign, because 127.0.0.1 doesn't require the hosts file to resolve and the '#' sign denotes a comment line.

A:

Totally forgot about this open question. As it turns out, if you copy the contents of the file, paste it into a new Notepad, delete the original file, and then save HOSTS again to C:|Windows\System32\Drivers\etc then it works.

