I have setup MAMP on Windows 10 successfully. I want to work on WordPress sites locally and commit changes to the live site via Git. (Update: I've answered my own question below.)

  1. I get that a common workflow is to run a SQL query to edit all the absolute links from www.mysite.org/internal-link/sample.html to localhost/internal-link/sample.html and back, but isn't it (a) safer not to touch the database and (b) faster simply to comment/uncomment a few lines in a .conf file each time one works on the site?

  2. Assuming the answer to question (1) is yes, how do I get the hosts, httpd.conf, httpd-vhosts.conf, and .htaccess files working so that if I go to "www.mysite.org" in the browser, it finds the WP installation in the corresponding local folder (e.g. c:/MAMP/htdocs/mysite-dev/*) so that the local WordPress "thinks" it's the live site?

I'm running PHP 7.4.1 in MAMP 4.2 (not pro). Currently, when I go to localhost in my browser with Apache and MySQL servers on, it shows the site in c:/MAMP/htdocs/example1-local-folder-name/. If I go to https://example1.org/ it goes to the live site. My MAMP configuration is as follows:

drivers\etc\hosts:     example1.org
::1           example1.org


ServerName example1.org
DocumentRoot "C:\MAMP\htdocs"

<Directory />   # "default" configuration unchanged
    Options FollowSymLinks ExecCGI
    AllowOverride None
    Order deny,allow
    Allow from all

<Directory "C:\MAMP\htdocs">  # This is the only line I changed
    Options Indexes FollowSymLinks ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all


NameVirtualHost *:80

<VirtualHost *:80> 
    ServerName example1.org
    ServerAlias www.example1.org *.example1.org
    DocumentRoot "C:/MAMP/htdocs/example1-local-folder-name"
    ServerAdmin [email protected] 
    ErrorLog "example1-error_log" 
    CustomLog "example1-access_log" common 

.htaccess (in c:/MAMP/htdocs/example1-local-folder-name/):

# I don't know what to put here aside from the standard WP rewrite block. 
# For now I have this file commented out

Thanks for any pointers & apologies if this question has been asked before.

1 Answer 1


By default, Windows does not allow DNS redirection!

There is no set of commands within hosts, httpd.conf, etc that will cause 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 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 *.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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.