Situatie
Your hosting provider may offer you a temporary URL in the http://IP/~username
format (where IP
represents the server’s IP address and username
represents the cPanel account name) to access your website. This is useful, for example, if you migrate your website to a new server and want to test the site before you point the DNS records to it.
However, some sites will not work with a temporary URL. For those sites, you can configure your workstation with the server’s IP address. To do this, modify your workstation’s /etc/hosts
file to use the server’s domain name and IP address.
This document explains how to modify your workstation’s /etc/hosts
file.
Solutie
Modify the /etc/hosts
file
The following methods allow you to modify your workstation’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 public DNS entries, you must manually remove the domain name and IP address in the /etc/hosts
file.
MacOS® and Linux®
To modify your /etc/hosts
file if your workstation runs MacOS or a Linux distribution, perform the following steps:
- On your workstation, open the
/etc/hosts
file with your preferred text editor. - Add the server’s IP address and domain name under the last entry in the file, for example:
1234
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 username.example.com
Note:
In this example,
1.2.3.4
represents the server’s IP address, andusername.example.com
represents the domain name. - Save your changes.
- Reload your browser for the changes to take effect.
Leave A Comment?