Testing sites prior to DNS transfer

My favorite method to test a site prior to changing the DNS (to point to the new IP address) is to edit one’s own local hosts file. The hosts file is usually located in C:\windows\system32\drivers\etc\hosts (Open with notepad) or /etc/hosts (on OSX and probably *nix). The only thing to keep in mind is to remember to change the setting back later so you dont accidentally make changes on the new server thinking it is the old server or vice versa. The hosts file will be used over the DNS server to map a domain to an IP.

Below is the format of the hosts file with the IP address first followed by the domain/subdomain. You may need to enter both the www and non-www versions depending on your site

#you can comment out entries with the pound sign
127.0.0.1 localhost #this entry should be there by default and is the reason why http://localhost points to http://127.0.0.1

123.10.11.123 www.actualsite.com
65.32.5.74 www.anothersite.com
65.32.5.74 anothersite.com
#8.8.8.8 www.tested.com

Another pro-tip is to display a “fixed” bar at the bottom of the screen to identify that you are on the new server.
Below is a snippet of CSS to display the fixed bar at the bottom of the screen along with an IE6 (now deprecated and appreciated by developers world-wide) hack. You just need to add a div with the id “dev-footer” and put a message in there.


#dev-footer{
position:fixed;
left:0px;
bottom:0px;
height:20px;
width:100%;
background:#990000;
margin:0 auto;
text-align:center;
font-weight:bold;
color:white;
z-index: 9999;
font-size: 1.2em;
padding-top: 2px;
}
/* IE6 */
* html #dev-footer{
position:absolute;
top:expression((0-(footer.offsetHeight)+(document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight)+(ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop))+'px');
}

While we are talking about the hosts file, I should also recommend the LocalGhost software for Macs if you do local development with multiple sites. It is free (and open-source), stays in your MenuBar and allows you to add local host entries if you do local development and add the virtual hosts to your Apache httpd.conf file. You can check and un-check domains to take effect (or not) while you develop. So, I normally use the www.actualsite.com for my local development and when I want to test on the live server, I can just uncheck it from the menubar. It’s probably easier if you take my word for it and try this tool than my verbal explanation.