In certain situations we want to view the content of a hosting different from the one the domain points to. For example, when performing a migration from another provider to cdmon while the domain is still pointing to them, but we want to check whether the content on the cdmon server has been completed correctly.
IMPORTANT: We would like to point out that this change only affects your device. In other words, people who access the domain will still access the public IP of the domain; this change only applies to the device where it is made. This allows you to see how the hosting responds for a domain different from the one it publicly points to.
To modify the IP that the domain points to only on our device, we must configure the hosts file on our computer.
The process is slightly different depending on the operating system we use. In Windows it differs from Mac and Linux:
How to configure the hosts file in Windows
We must go to the hard drive where our Windows system is installed. Once there, the hosts file is located in Windows/System32/drivers/etc
Next, we will edit the hosts file. To do this, double-click on the hosts file and it will ask which program we want to use to edit it. We will select Notepad to make the changes:
This file requires administrator permissions to run, so if we are not using the administrator user we must run the file as administrator by right-clicking:
Once inside the file, we must enter the domain name we want to modify and the hosting IP it should point to. Example:
As indicated, we must enter the hosting IP we want to visualize and the domain that should point to that IP.
Finally, when accessing the domain (in the example domain.com) it will respond using the assigned IP.
IMPORTANT: If we want to revert the changes, we only need to access the hosts file in the same way and delete the lines we added.
How to configure the hosts file in Mac and Linux
The process on these operating systems is much simpler, since we can do it quickly from the terminal.
To do this, we must open the terminal/console from our applications:
Next, we must run sudo nano /etc/hosts and it will ask for our user password, which we must enter:
We will now be inside the hosts file, so we must enter the domain name and the hosting IP as shown in the following image:
IMPORTANT: If we want to revert the changes, we only need to access the hosts file in the same way and delete the lines we added.