By default, Windows does not allow DNS redirection!
There is no set of commands within hosts, httpd.conf, etc that will cause 127.0.0.1 sample.com
in your hosts file to redirect all requests for sample.com
to localhost.
(That said, I experimented with various configurations of the standard hosts line and determined that (on Win 10 and MAMP), if you use 127.0.0.1 sample-com
in the hosts file, and ServerName sample-com
in the httpd-vhosts.conf file, you will get the local site by typing sample-com
in the browser (without the word “localhost”). However, this is useless, as it would still require you to run UPDATE commands to change the live url throughout your WordPress database.)
In addition to no redirection, if you have 127.0.0.1 *.sample.com
in your Windows hosts file, the wildcard does nothing — unless you have a “helper” program to add functionality to the internal TCP/IP engine.
One such helper program is here: https://coredns.io/ or https://github.com/coredns/coredns
I will post an update when I have time to test that setup.
Credit goes to this post for the needle in the haystack that led me to Coredns.