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.)
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?
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:
127.0.0.1 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> <Directory "C:\MAMP\htdocs"> # This is the only line I changed Options Indexes FollowSymLinks ExecCGI AllowOverride All Order allow,deny Allow from all </Directory>
NameVirtualHost *:80 <VirtualHost *:80> ServerName example1.org ServerAlias www.example1.org *.example1.org DocumentRoot "C:/MAMP/htdocs/example1-local-folder-name" ServerAdmin firstname.lastname@example.org ErrorLog "example1-error_log" CustomLog "example1-access_log" common </VirtualHost>
.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.