Beware of spacing in Windows7 hosts file

The hosts file of Windows, by default located in %SystemRoot%\System32\drivers\etc, can be a bitch to edit, so it seems.

I had an XP machine running just fine with the entries from my hosts file. I then made a Windows7 partition on the same machine, with the same entries in the hosts file. Didn’t work at all. It seemed as if the hosts file was completely ignored. So I did some searches on that and tried a lot of stuff. Even up to checking out the registry entry for the path, and the system variables, if they were set to correct values.

However, nothing seemed to work. Until I saw some other example hosts files that were formatted as

Notice the single space. In my own hosts file, all entries were nicely outlined by use of multiple spaces, to make it easier to read. So it seems now that in Windows7, unneeded whitespace is not thrown away anymore. Threw away the “markup whitespace” and everything worked in an instance.

I don’t have any clue on how many people use the hosts file intensively, but it might not be such a bad thing for the folks in Redmond to have a look at that.

Word to the wise: beware of spacing :)

This article is part of the GWB Archives. Original Author: Jan Schepens

New on Geeks with Blogs

  • We Won The One Award I Actually Care About

    Full Scale made the Inc. 5000 for the fifth year straight, the 12th listing across my three companies. Here is why the one award you cannot buy is worth stopping for.

  • Your Customers Build the Features Now

    I let a tool I liked sit dead for a year rather than build the features I wanted. An MCP server meant I never had to, and your customers can do the same to your product.

  • Get the Size of a Directory in Linux the Easy Way

    du -sh for the quick answer, ncdu for the cleanup, df for the disk itself: every command for checking directory size in Linux, plus why du and df never agree.

  • Vim Search and Replace: The Ultimate Guide

    One :%s command replaces every match in a file before a find dialog would even open. The Vim substitute patterns worth the muscle memory: flags, ranges, capture groups, and multi-file edits.