Change the domain’s A-Record (without changing the domain’s A -record)
In the old days of the internet there was no DNS system. Everyone kept a copy of all the hosts (this was before the days of websites) on the internet on a file on their computer. As new hosts were added to the internet an updated hosts file was sent round everyone on the internet so they could get their local copy updated. This system got out of hand as the internet expanded so it was replaced by the DNS system.
You can override the DNS for a domain on your local computer. This lets you view a website (or user ftp etc.) as it would appear on a different server or host, as though the domain pointed to a different location even when it doesn't.
Let’s say I was looking at moving example.com to a different server. Currently the domain is pointed to 93.184.216.34 and I’m going to be moving the site over to a new server at 123.123.123.123. I want to see how the site would look on the new server but I don’t want anyone else to see it. By adding a single line to my hosts file I can ‘repoint’ the domain to the new IP address but just for myself.
You will need elevated permissions on whatever system you are using. If you are on a restricted work computer this may not be possible.
On Windows the hosts file is located at the following path: C:\Windows\System32\drivers\etc\hosts Find notepad or a text editor of your choice. Right click on it and ‘run as administrator’ then file open and find the file with the path shown above (you may need to select the option ‘view all files’ to see the file listed as it is not a txt file) Add the line:
123.123.123.123 example.com www.example.com
This will point the both the domain and the www subdomain to the chosen IP address. You will need to restart your browser for this to apply.
On Linux or MacOS the process is the same except that the hosts file is located at /etc/hosts The vim text editor can be used for this by running the command in the Terminal:
sudo vim /etc/hosts
Add the line:
123.123.123.123 example.com www.example.com
This will point the both the domain and the www subdomain to the chosen IP address. You will need to restart your browser for this to apply.
You can re-open the hosts file using the same method as described above, delete the offending lines and save the file. (Don't forget to restart your browser for it to apply again.) Another option is to comment out the offending line. Adding # before any line in the hosts file comments it out. (So the text will remain but it will not do anything.)