How to Test Name-Based Virtual Hosting

domain-name-systemvirtualhost

Our website mysite.com is going to be hosted at a server with virtual hosting (name-based) at 10.20.30.40. However, the DNS records are currently pointing to 66.77.88.99.

I want to keep those DNS records pointing to 66.77.88.99 while testing; is there any way for me to access 10.20.30.40 anyway?

Since the target server uses virtual hosting, I cannot simply enter the IP address to test on the target site. Also, I have no control over the target server, and can therefore not set up a subdomain to test on.

Best Answer

Put the host names with appropriate IP address in your hosts file (/etc/hosts in Linux, %SYSTEMROOT%\System32\Drivers\etc\hosts on Windows systems) like this:

# IP address of your test host     FQDN of your domain
10.20.30.40                        www.mysite.com

Do not forget to remove the entries after testing.