Editing Your Hosts File

The Objective

When setting up a site on Yottaa, the support team may ask you to edit your hosts file to preview your optimized site. This allows you to see how your site will look and feel when running on Yottaa without affecting live traffic (your customers). Editing your hosts file only affects the computer you do it on, so if you edit your hosts file on your desktop and then try to access your site from your laptop, the laptop will behave as though nothing has happened, unless of course you edit the hosts file on your laptop too.

Prerequisite

Before you begin, you will need your site's Yottaa Preview URL. Log into your Yottaa account at https://apps.yottaa.com, then go to the "Content Optimizer" tab; make sure the desired domain name is shown in the "Sites" dropdown on the blue bar, then copy the URL given on the "Preview URL" line (it should look like "3cead289fb2b27ad2f7b0c321007aef9.yottaa.net").

Editing Your Hosts File on Windows

  1. Obtain the IP address of a Yottaa server near you:
    1. Open the command prompt
    2. Type nslookup followed by a space, then paste the Preview URL by right-clicking in the command prompt window and choose "Paste" (CTRL+V won't work) and press ENTER
    3. Copy the IP address shown on the "Address" line by right-clicking on the command prompt window, choosing "Mark", highlighting the IP address with your cursor, and pressing ENTER to copy to the clipboard
  2. Open Notepad as Administrator:
    1. Click Start and type notepad in the search box (but do not press ENTER)
    2. RIGHT-click "Notepad" in the search results pop-up
    3. Choose "Run as Administrator" from the menu
  3. Add a new entry to your hosts file:
    1.  Scroll to the bottom of the file and add a new line
    2. Paste the IP address copied from step (1c), type a space, then type in your site's domain name (such as www.mydomain.com)
    3. Save the hosts file and close Notepad

Editing Your Hosts File on Mac or Linux

  1. Obtain the IP address of a Yottaa server near you:
    1. Open the Terminal (on a Mac, this is under Applications > Utilities; its location varies by distro in Linux)
    2. Type nslookup followed by a space, then paste the Preview URL
    3. Copy the IP address shown on the "Address" line
  2. Open your hosts file in vi:
    1. In the terminal, type sudo vi /etc/hosts and press ENTER
    2. You may be prompted to enter a password; this will be the same password you use to log into your computer
    3. Type :$ (a colon and a dollar sign) and press ENTER to navigate to the bottom of the file
  3. Add a new entry to your hosts file:
    1. Press "o" to add a new line at the end of the file
    2. Paste the IP address copied from step (1c), type a space, then type in your site's domain name (such as www.mydomain.com)
    3. Press ESC, then type :wq (a colon, followed by "w" and "q") and press ENTER to save the file and quit vi

Finishing Up

Once you have completed the steps above, you may safely close any command prompts/terminal windows you still have open from the procedure. Since you have probably browsed to your site recently, it is strongly recommended that you clear your browser's cache prior to attempting to view your site on Yottaa. After clearing your cache, you may browse to your site (i.e. www.mydomain.com) to view the Yottaa optimized version! You can confirm that you are viewing the Yottaa-optimized site by viewing the source of the page; you should see references to URLs like "cdn-us-e.yottaa.net" in the source code.

Undoing the Changes on Windows

Follow steps 1 and 2 for Editing Your Hosts File on Windows, then find the line you added in step 3, select it (making sure not to select anything else) and delete it, then Save and close Notepad.

Undoing the Changes on Mac/Linux

Follow steps 1 and 2 for Editing Your Hosts File on Mac or Linux. Confirm that your cursor is on the line you added in step 3, then type dd to delete the line. Then type :wq (as in step 3c) and press ENTER to save the file and quit vi.

Have more questions? Submit a request

Comments

Powered by Zendesk