Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
Please post your hosts file –  John T Sep 26 '10 at 21:02
    
Can you give a specific example? What is the configuration, what steps do you take to test it, what do you expect to happen, and what actually happens? –  Stephen Jennings Sep 26 '10 at 23:41
    
I second post your hosts file. Also try the hosts file on the XP machine where the other hosts file works. –  Andrew J. Brehm Nov 22 '10 at 9:37
    
Make sure you haven't saved hosts files as hosts.txt accidentally..! Small thing but worth checking. –  user207952 Mar 17 '13 at 6:02

4 Answers 4

For Windows 7,

  1. Open Notepad in Run as Administrator mode.
  2. Now you can see these lines...

    # localhost name resolution is handled within DNS itself.
    #    127.0.0.1           localhost
    #    ::1                 localhost
    
  3. Add new line for your domain.

  4. 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
    
  5. Now save the hosts file. If it prompts to save it elsewhere then you forgot to open Notepad as administartor.

  6. Go to Windows' command promt and run this command ipconfig /flushdns
  7. 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.

share|improve this answer
    
Please, please take a moment to read the formatting/Markdown help and keep it simple instead of unwanted garbage HTML –  Sathya Jul 12 '12 at 19:07
1  
Upvote because this is the right way to do it. –  Rob Jul 12 '12 at 19:11
up vote 1 down vote accepted

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.

share|improve this answer
1  
This is NOT the standard way when editing the hosts file, you don't need to copy and paste the contents like that. Not every time, anyway. –  TFM Mar 17 '13 at 6:42

According to Microsoft, the DNS resolution order has not changed.

share|improve this answer

Have you tried running an IPCONFIG /Flushdns?

It may be that Windows 7 caches the lookups in a different way to older versions, leading to slightly different behaviour.

share|improve this answer
    
Yes, I've tried that amongst many other things. I've currently NO idea why the HOSTS file seems to be completely ignored in W7. –  Sootah Sep 26 '10 at 22:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.