How to test your site before moving DNS

Discussion in 'Knowledgebase & FAQ' started by KH-Jonathan, Jun 25, 2013.

  1. KH-Jonathan

    KH-Jonathan Director of Managed Services Staff Member

    There are two methods for accessing your site prior to moving DNS which will be covered in this article. One is using cPanel temporary URLs, and one is editing the local "hosts" file on your computer to force your domain to resolve to your new server.

    cPanel Temporary URL
    This method will not work if your server runs DSO as it's PHP handler with the mod_ruid2 Apache module installed.

    In cPanel, you can access your site prior to moving DNS by entering a URL using the following format in your browser.

    One downside to using this method is that Apache mod_rewrite rules in .htaccess files will not work. This will result in some Wordpress, Joomla, and other CMS sites looking broken - even though they aren't and moving DNS and using your domain to access it would resolve the "problem".

    Code:
    http://<sharedip>/~<username>
    There are two things in this that you will need to replace.
    • <sharedip> - This is the shared, usually primary, IP of your VPS.
    • <username> - This is the cPanel username of the account you want to access.
    A "working" example of this could be something like this.
    Code:
    http://67.222.1.2/~myusr
    This would load the account "myusr".
    Editing Local "hosts" File
    This is the preferred method to test your site if you are using Apache mod_rewrite rules. This method is a bit more in-depth and requires some working knowledge of your operating system. I will attempt to break it down as much as possible.
    Windows
    1. Locate the HOSTS file on your computers. Typically it is in one of the following locations:
      • Windows NT/2000/XP/2003/Vista/7 - C:\windows\system32\drivers\etc\hosts
      • Windows 95/98/Me - C:\windows\hosts
    2. Open this file with a text editor such as Notepad or Wordpad.
      • Right-click on Notepad and select the option to Run as Administrator - otherwise you may not be able to open this file.
    3. Then, open the file. Consider performing a "Save As" so you have an original copy of the file that you can restore later. You will see two columns of information, the first containing IP addresses and the second containing host names. By default, a windows hosts file should be similar to the following
      Code:
      127.0.0.1 localhost
      • You can add additional lines to this file that will point requests for a particular domain to your new server's IP address. Example:
        Code:
        127.0.0.1 localhost
        67.222.1.2 example.com
        67.222.1.2 www.example.com
    1. Save your changes.
    2. Restart any currently open browsers. You may also want to flush your DNS cache. In Windows XP, go to Start, and then Run, then type "cmd" and hit enter. Type the following:
      Code:
      ipconfig /flushdns
    3. Visit your new site using http://example.com/ or http://www.example.com/
     
    Last edited: Nov 25, 2014

Share This Page