How do I "test" name-based virtual hosting?

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.


As pointed out adding it to /etc/hosts is one option.

I usually use the Modify Headers Firefox Addon.
I don't have to change system configuration and become root everytime I want to test this.

Another way is using cURL like this:

curl -H "Host: mysite.com" http://10.20.30.40

This is especially useful for quick troubleshooting.
And you don't have to remove anything after you are done.