The most crucial thing you should do before pointing out your name is to test your website before switching to a new hosting company. Ensuring your site is fully functional before making the changeover can help ensure a successful migration.


Redirecting via System hosts File


The Windows operating system is used in these examples. Scroll down to the "Linux and macOS users" section for instructions for Linux and macOS.


Staging your domain using the hosts file on your PC is the most effective way to test your website. By using this technique, you can avoid waiting around for DNS propagation, which could take some time.


However, this will only work for the local system. If someone else would like to test the site, they will need to follow the same steps for modifying the hosts file.


Open your text editor of choice. If you’re a Windows user, use Notepad with administrative privileges to modify the hosts file.


  1. Open Windows menu (click Windows icon or use Windows keyboard key)
  2. Type “Notepad”
  3. Right-click “Notepad”
  4. From the pop-up menu, select “Run as Administrator”


Open your system’s hosts file. The location of the file is:


C:\Windows\System32\drivers\etc\hosts


Use Notepad to convert "Text Documents" to "All Files" if there is nothing in the etc folder. This will display the hosts file along with everything else in the folder.


Using your server IP, add the following lines to the file on a new line at the bottom of the hosts file:


SERVER_IP_HERE ggexample.com 
SERVER_IP_HERE www.ggexample.com


Note that SERVER_IP_HERE needs to be replaced with your actual server IP address. The ggexample.com references should be replaced with your actual domain name.


Here is an example of what your entry should look like :


xx.xx.xx.xx ggexample.com 
xx.xx.xx.xx www.ggexample.com

Go to File and Save the hosts file. You don’t want to use “Save As” because you’re keeping the hosts file as-is with your added redirect entry.

Restart your web browser and navigate to your website. The site will now load from the GreenGeeks server.

Linux and macOS users

For Linux and macOS users, the location of the hosts file is:

/etc/hosts

You have to make changes to the hosts file as a superuser.

macOS

  • Click the F4 key to access launcher
  • Enter terminal in the search field
  • Click the Terminal icon

To open the hosts file with Nano as a superuser, use the following command:

sudo nano /private/etc/hosts

Since you are executing a command as a superuser, macOS will ask for the password for your Mac user account. Enter your password and click the ENTER key.

Add these lines to the bottom of the hosts file:

SERVER_IP_HERE ggexample.com SERVER_IP_HERE www.ggexample.com

Replace SERVER_IP_HERE with your server IP address and replace ggexample.com with your domain name.

Your entry should look like:

12.34.56.78 ggexample.com 12.34.56.78 www.ggexample.com

When you are finished editing hosts file:

  • Click CTRL + X on your keyboard
  • Enter Y to save changes
  • Click the ENTER key

Linux

To edit with the Nano text editor, use the command:

$ sudo nano /etc/hosts

or to edit with the gedit text editor:

$ sudo gedit /etc/hosts

Add these lines to the bottom of the hosts file:

SERVER_IP_HERE ggexample.com SERVER_IP_HERE www.ggexample.com

Replace SERVER_IP_HERE with your server IP address and replace ggexample.com with your domain name.

Your entry should look like:

12.34.56.78 ggexample.com 12.34.56.78 www.ggexample.com

Save the changes by clicking ctrl+X on your keyboard.

Removing the Redirect Entry

To revert this change, simply remove the lines you added and save the file again. This will direct the site back to the original host. You may need to do this before visiting your domain registrar to change the nameserver.