Search code examples
http-redirectdnsipvirtualhosthost

Access virtual host without domain pointing to it


I have a domain which pointed to an IP address (A). This IP address hosts several other websites with their domains. I now forwarded this domain to another host but I also need to access the old site which now does not have a domain pointing to it. Of course I can't just access the old site by typing the IP address into the browser. How can I do it instead?


Solution

  • If you're on unix, you should modify the /etc/hosts file; C:\Windows\System32\Drivers\etc\hosts if you're on Windows. (This will likely require admin privileges.)

    This overrides the public DNS which would otherwise map an IP to a domain name. The change tells your machine that the old IP address is the location of example.com, where your hosts file has a line that reads:

    xxx.xx.xx.xx example.com www.example.com
    

    And xxx.xx.xx.xx is your old server's IP.

    Remember to comment out or remove the line when you're done! You may confuse your future self, otherwise!