The underlying intent here (figure out if it's an existing customer of our locally installed apps when they visit our website) doesn't seem bad, but I certainly dislike both the hosts file and localhost detection options.
I dislike the intent too. A website should simply not be able to see which apps I've got installed. Imagine Facebook doing stuff like this in order to know what ads they should serve.
I'm curious if there's a "good" way to do this.