Child pages
  • How to Modify your hosts File
Skip to end of metadata
Go to start of metadata

Overview

WHM's Apache mod_userdir Tweak interface (WHM >> Home >> Security Center >> Apache mod_userdir Tweak) allows you to access to your websites through a temporary URL in the http://IP/~username format.  However, some sites will not work with a temporary URL. For those sites, you can configure your local system with the server's IP address. To do this, modify your system's /etc/hosts file to use the destination server's domain name and IP address. 

This document explains how to modify your system's /etc/hosts file.

Modify the hosts file

The following methods allow you to modify your system's /etc/hosts file.

Important:

Your workstation's Operating System will not remove your changes to the /etc/hosts file. If you want the domain that you added to use normal DNS, you must manually remove the domain name and IP address in the /etc/hosts file.

MacOS® and Linux

To modify your /hosts file if your server runs a MacOS® or Linux distribution, perform the following steps:

  1. Log in to your server as the root user via SSH.
  2. Open the /etc/hosts file with a text editor.
  3. Add the destination server's IP address and domain name under the latest entry in the file, for example:

    127.0.0.1		localhost localhost.localdomain localhost4 localhost4.localdomain4
    ::1		localhost localhost.localdomain localhost6 localhost6.localdomain6
    192.168.0.20		example.com
    1.2.3.4		user.example.com

    Note:

    In this example, 1.2.3.4 represents the destination server's IP address, and user.example.com represents the domain name.

  4. Save your changes.

  5. Reload your web browser for the changes to take effect.

Microsoft® Windows®

Click the tab that corresponds to your version of Microsoft Windows.

To modify the /hosts file on a Windows® 8 or Windows® 10 system, perform the following steps:

  1. On your keyboard, type Win+X on the keyboard, or click the windows () icon in the lower-left corner of your desktop interface to to open the Start menu.
  2. Enter Notepad in the search text box.
  3. Right-click Notepad and select Run as Administrator.
  4. From the Notepad , open the following file:

    C:\Windows\System32\Drivers\etc\hosts 
  5. Add the destination server's IP address and domain name under the latest entry in the file, for example:

    127.0.0.1		localhost localhost.localdomain localhost4 localhost4.localdomain4
    ::1		localhost localhost.localdomain localhost6 localhost6.localdomain6
    192.168.0.20		example.com
    1.2.3.4		user.example.com

    Note:

    In this example, 1.2.3.4 represents the destination server's IP address, and user.example.com represents the domain name.

  6. Save your changes.
  7. Reload your web browser for the changes to take effect.

To modify the /hosts file on a Windows® 7 or Windows Vista® system, perform the following steps:

  1. Click Start.
  2. Enter Notepad in the Start menu search text box.
  3. Right-click Notepad and select Run as Administrator.
  4. From the Notepad, open the following file:

    C:\Windows\System32\Drivers\etc\hosts 
  5. Add the destination server's IP address and domain name under the latest entry in the file, for example:

    127.0.0.1		localhost localhost.localdomain localhost4 localhost4.localdomain4
    ::1		localhost localhost.localdomain localhost6 localhost6.localdomain6
    192.168.0.20		example.com
    1.2.3.4		user.example.com

    Note:

    In this example, 1.2.3.4 represents the destination server's IP address, and user.example.com represents the domain name.

  6. Save your changes.
  7. Reload your web browser for the changes to take effect.

Additional documentation