« Absolute Vs Relative URLs | Social Marketing: Some Links Are Radioactive »
June 18, 2008
Using the Windows Hosts File To Test A Site
By Scott Goodyear
In my last post I spoke a bit about Absolute Vs Relative URLs. In this post I will talk about the Windows Hosts file. If you have a site mock up that you want to put online and test out but the files are not yet ready to be deployed on the live site, you can test your site by using the Windows Hosts file.
Essentially when you type a URL into your browser's address bar, it has to resolve the string of letters into an IP address. Because URLs tend to be unique in nature, there is only one www.marketposition.com, one www.google.com and so on, there is normally a specific IP address or IP range associated with a particular URL. Your computer also checks a local file on your system to see if there are any special instructions related to resolving a URL.
How To Edit The Hosts File
- Search on your computer for the "hosts" file.
On my computer this is located at:
C:\WINDOWS\system32\drivers\etc
this can vary depending on your system.
- Open this file up in notepad.
- Here you can add the IP address where the mock up site is hosted. And the actual URL where the site may eventually be hosted. Or you can put just about anything in. In my own case, I've added a few shortcuts in my hosts file so I can type in phrases like "edit", "blog", "payroll", etc. and have my browser always take me to my preferred sites rather than having to type a long URL or click through a mess of nested bookmarks - geeky, I know.
More Info On The Hosts File...
This same sort of trick is often employed by libraries and schools to block access to certain sites or redirect traffic back to an internal page. If YouTube is any indication, this is not an entirely fool proof methodology. I've found a lot of kids posting videos on how to get around this...
Businesses use this not only to test sites that aren't live yet, but also so that employees can type phrases into their browsers like "HR" and get to internal HR pages and so on.
Unfortunately, this is also a way that some viruses and spy ware can get on your system and try to phish for your information. So it's not a bad idea to be aware of this file and check it once in a while for odd entries.
Introducing The Hosts File To A Colleague
If you want to have some fun with an SEO colleague in your agency... wait until they leave their desk then head over to their computer. Pull up a news page like this one and leave it up in their browser.
Click through "start-->run" then type in CMD and hit enter. Type in: ping www.google.com
Copy down the IP address that shows up. Open their hosts file and put something similar to this in:
209.85.173.99 www.yahoo.com
Save the file and perform a www.yahoo.com search.

Bring the news page back up and when they get back:
"Oh wow Bob, looks like Yahoo actually sold out to Google, it's not just advertising... Just...wow."
Have them perform a www.yahoo.com search.
Once they are past the "No way!" stage of your hijinx, you can get back to business and show them how to edit the hosts file so they can test a client's site with the actual URL being used.
← What is this?
