How to use a fully qualified domain name without an active DNS record for testing

Sometimes when you are moving sites between servers you might run into the problem that you must make contact with the new location by its real hostname. If you don’t want the old DNS settings to be adjusted yet and want to test if everything runs fine first on your web server you can adjust the hosts file.

I’ll explain this for usage on Mac OS X but of course it works the same on any other *nix environment.

Open Terminal form /Applications/Utilities/Terminal.app and enter the following command:

Sudo will ask for your account password here.

After entering your password the program Vim will open the hosts file.

At the bottom add the following line by entering insert mode by pressing the i key:

This will point test.domain.nl to 160.79.58.10.

Now we are done editing we need to save the file first before this will work, this can be done by pressing Esc to exit insert mode and then enter :w to write the file.
You may also want to exit Vim by entering :q or the quick combination :wq.

Your hosts file should look something like this: