Viewing your site before it goes live - Flush DNS
Posted on February 27, 2008
Filed Under Code Snippets, Technical Resources |
How to Flush DNS - See New Site Before It Resolves Live!
One of the greatest techniques ever used by responsible web designers.
I was chatting with Mack McMillan of UltimateIDX the other day when we got onto discussing the subject we frequently encounter with clients. Many times clients want to see their blogs and websites prior to them going live and many times that isn’t easily done without some clever techniques I’ll reveal herein. After having encountered this many times I realized that I should come up with a small guide on "how to build and view a site development prior to it going live" when I came up with a little tool to distribute in order to help. So this post is generically in response to a common question being asked in forums.
How can I see my site before the DNS resolves or before I switch servers?
Before we answer that I want to toss a few scenarios at you in the form of questions so I can set the frame of mind and reference for you to better understand why this technique is so very important. We look at preserving page urls for page rank along with site migration and server migration while maintaining the old site.
Lets say you have a brand new hosting account and on that hosting account you upload your site to the server and you eagerly wait for your DNS to resolve. After two hours go by you begin to get impatient (even though dns can take 24+ hours to resolve) and you begin to seek a solution. After all, you want to install your shopping cart, WordPress blog, or Joomla site and simply cant wait. How can you view your site with full resolving URL even if DNS hasn’t resolved? Thats question 1.
Now lets say that you have a site you are migrating from an old service provider, hosting company, designer or whatever and you want to verify that the migration went well PRIOR to you switching DNS. Lets word this question accordingly; How can I see and test my site before I switch DNS? Naturally this would apply to site migrations where switching servers are also involved. Thats question 2.
One last question related to these scenarios would be instances where you are simply seeking a web site redesign or change in site tools and wish to preserve URL’s This happens with site migrations where, for instance, Realtors would be leaving a proprietary system and they wish to move to a more widely supported one as in the case of the thousands of recent Real Estate Webmasters and Advanced Access migrations to a CMS solution. Many times people then ask the question; How can I preserve my links for page rank during a redesign? This question gets a bit more involved when its worded for instances where a site owner wants to keep his or her existing site live while the migration and redesign takes place, most often on an alternative server. Thats question 3.
Answer: Preserving Page Rank - Migration - URL - Testing
One of the most common techniques used by web designers and developers is to build client sites on servers not accessible to the open web and by doing so a responsible designer will prevent search engines from accidentally indexing the site prematurely. Although many opt for the sub directory method which can work well, there is a danger in using this technique as referrers can provide Search Engines with a path necessary to view the work in progress. Follow my logic for just a moment and you will see how this plays out. We’re going to use a site that is live and online today which was a redesign using a client provided template layout as it was migrated from the old design to the new without missing a beat in the search engines. This site we use for this article was Go All Pro Realty and the URL I’ll use in this post is http://www.goallpro.com so from this point on I’ll reference that site in the example.
Answering all questions above in those scenarios I take Go All Pro Realty which had been created using Microsoft Front Page. The site was redesigned for Joomla in which we built the site on a separate IP as opposed to a sub directory where we could use the technique I’m about to reveal for optimal results. After we took all of the content from the old static site and pasted it into the WYSIWYG editor of Joomla we then set out to correct and preserve the URLs and make 301 Redirect changes where links would not be preserved. The tool we used was a plug-in we offer called OpenSEF for Joomla. After all the data migration was done we needed to verify the content and the URL’s in a way that we can also verify the page rank, linking, back linking and other aspects without changing the DNS. How can this be done? How can we view http://www.goallpro.com with our browser and end up visiting the new project location without changing the DNS? Let me explain.
Since I needed a way to view the new site after switching techniques on the new server with the new install of Joomla, what we came up with was a simple modification to a windows file known as the "hosts" file. For those not familiar with networking and IP mapping, the hosts file is used to contain mapping of IP numbers to host names and each time the file is loaded into cache from reboot, those host names listed will resolve to the IP they are associated with regardless of the actual IP of the domain. What this means is that if your host file has a reference to a site like say JaredRitchey.com associated to the IP for google, each time you type in JaredRitchey.com it would resolve to google. This is a common issue with PayPal spoofs and other types of deceptive viruses that modify your host file to get your browser to resolve to a server other than your intended target location.
So in our instance answering those questions above, I need to type in http://www.goallpro.com and have it resolve to a new location on a new IP even though the DNS for the domain has not been switched. Lets break down the steps and you can try this for yourself.
Fist we modify the hosts file in your windows system; To do this you navigate to this path on your windows system, C:\WINDOWS\system32\drivers\etc then you open the hosts file using an editor that does not alter or modify the raw text. Some ideal choices are simply notepad on your system or NotePad++ which is a free download.

Click on the image below to examine a larger profile. Basically what we do is take the host file and add in the domain url and assign it to our testing servers IP. Now for those of you interested in simply resolving the new site on a new hosting company for the purpose of installing you would make sure your IP the domain is associated with follows the format your hosting company provides. This is ideal for sites that are hosted on a shared server where an IP is used on many domains. The format for instance on one of my servers looks like 123.4.5.67/~accountname/ It will vary depending on hosting company. Look at the example below;
Now we simply flush the DNS on our system and reopen the browsers (again, make sure the browser cache is cleared)
To do this open the command prompt by visiting START >> RUN and type in command to load the command prompt.

At the command prompt you simply type in the following and press enter "ipconfig /flushdns" (no quote marks) then after the DNS flushes you type in "exit" (no quote marks) and press enter. Now I’ve created a batch file to flush dns because I do it frequently in working with servers and domains and you are welcome to it. You can verify the contents of the batch file by simply right clicking on it and opening it in Notepad++ Basically you simply put it on your desktop and double click it when you want to flush the DNS.
A quick note on clearing cache in your browsers. In FireFox this is easy enough by holding down CTRL + SHIFT and pressing the Delete Key. You end up with a dialog box like this;

Now that all these things have taken place you should be able to just open your browser and type in the URL and have it resolve to the new target location without the need to change your DNS to the testing server.
I’m open for comments and suggestions regarding this so feel free to sound off.
Comments
Leave a Comment
If you would like to make a comment, please fill out the form below.
Shopping Cart
Recently
- WordPress Menu Manager
- WordPress and Open Source for Realtors
- WP Featured Documentation!
- WP Featured v1.3 Features
- WP Featured Example
- RETS and OPEN REALTY
- New WordPress OpenRealty Component
- WordPress Featured Listings Plugin v1.0.2
- Realtor Blogs Themes - The Brokers Edge
- WP Featured Listings Plugin Download
Categories
- Code Snippets
- Design
- Open Listings
- Open Realty
- Portfolio
- Products
- Products in Review
- Products in Review
- Professionals In Review
- Real Estate News
- Real Estate Websites
- Technical Resources
- Template Design Kit
- Uncategorized
- Week in Review
- WordPress Wisdom
Archives
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007

[...] location to another site. Well I came up with a solution that seems to work well. You can visit My Blog Post With File __________________ http://www.JaredRitchey.com Where I work Where I [...]
Excellent description Jared… I suppose I am probably like many people that are well equipped to do almost anything with the computer, until getting into DNS where I usually get lost.
Since I will be needing to do this very shortly to “see and test my site before I switch DNS”, this instruction is timed well. I almost want to believe this was written just for me…