Test against simulated real domain names in etc hosts

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the web-development category.

Last Updated: 2024-04-24

My localhosts subdomain-parsing in OxbridgeNotes was working in test and development environments but had a bug in production. I didn't want to have to deploy each time to try alternatives so I came up with this temporary solution:

The trick to simulating production URLs locally, without modifying the actual network, it to modify the /etc/hosts file.

By doing the following, I was able to test-drive URLs like www.oxbridgenotes.co.uk in development and debug.

127.0.0.1 www.oxbridgenotes.co.uk
127.0.0.1 www.oxbridgenotes.com
127.0.0.1 en-au.oxbridgenotes.com