Latest Articles
Using the Windows Hosts File To Test A Site
June 18, 2008 By Webposition SEO Team
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.
Absolute Vs Relative URLs
June 17, 2008 By Webposition SEO Team
By Scott Goodyear
Working on a new site? Testing code before it goes on a live server? Reading through Google Groups, John Mu talks about the pluses and minuses related to absolute vs. relative URLs. He says that as a negative absolute URLs “cannot be tested on a staging / testing server (e.g. locally) (unless you insert the links dynamically)”. I disagree with his suggestion as I’m a fan of absolute URLs and believe that there is a way around this, by using the Windows Hosts file on your PC. This first post discusses absolute vs. relative URLs in case you are not familiar with the difference.
Absolute Vs. Relative URLs
In case you are unfamiliar with absolute vs. relative URLs, a quick recap no what they are…
In the fake blog page mock up below, I have a few absolute links to sites that currently exist. When you click through the link, they work because the link exists.
| Boy, I’m such a geek. I love these fan made Star Wars action figures, this At-At Stroller, and this Tie Fighter computer case mod. This stuff is really inspiring and reminds me of the awe I had as a kid, watching the original movies. The newer movies /sigh, Jar Jar Binks…need I say more? |
What if I wanted to add navigation to the page such as this:
| <previous post | main | next post > Boy, I’m such a geek. I love these fan made Star Wars action figures, this At-At Stroller, and this Tie Fighter computer case mod. This stuff is really inspiring and reminds me of the awe I had as a kid, watching the original movies. The newer movies /sigh, Jar Jar Binks…need I say more? |
Since the domain does not exist right now, lets pretend that the site is down as I’m moving to a new hosting company, an absolute link like this one will not work to test the navigation:
<a href=”http://www.scotts-starwars-memories.com/absolute_vs_rel.html#relative”>previous
post</a>
However I could use a relative link like this:
<a href=”absolute_vs_rel.html#relative”>previous post</a>
Thus if I’m testing the html page on my local hard drive I can still click through the link and see if the navigation works because my browser will add the first half of the link based on where the web page currently exists.
On the plus side, if I move this page to live web server, it will retain all of the relative URLs and I have very little if any edits to make in order to make sure that he page works as long as it works on my local hard drive. There are some caveats, but I won’t cover all of those, only one that John hints at…
“…Relative URLs:
+ make it easy to move content around
+ make it easy to test locally and on a staging server
- are easy to break if linking to content that isn’t moved as well
(stylesheet, graphics, etc)…”
Lets say you store your graphics under the main folder of your site like this:
http://www.scotts-starwars-memories.com/somegraphic.gif
and you usually save your HTML to the same location like this:
http://www.scotts-starwars-memories.com/chewbacca.htm
Then you move the HTML to a new location like this:
http://www.scotts-starwars-memories.com/archive/chewbacca.htm
If your coding on chewbacca.htm used a lot of relative linking, you really need to plan ahead or you’ll probably break items in the code. For example maybe that relatively linked graphic on chewbacca.htm now looks for the graphic at: http://www.scotts-starwars-memories.com/archive/somegraphic.gif … but you forgot too move all of your graphic files to the new folder structure… oops now you have broken images.
As John Mu says, there probably isn’t an “absolute” answer as to when you should or should not use absolute or relative URLs. It is mainly a matter of choice. In my next post, I’ll talk a bit about how the Windows Hosts file can be used to test a web site on your staging server regardless of if you use absolute or relative URLs.

