Flexible wp-config on localhost: many installs, maintained by cookies

This allows you to run multiple, ver different sites off one wordpress install by sharing one wp-config but having it direct requests to different databases based on the domain / location you’re accessing from.

So maybe you’ll have demo.localhost.com and demo2.localhost.com and you want them to share the same resources but go to different databases and you don’t want to keep switching the include in wp-config. This will let you pass a variable to the URL and then store it in a cookie that’s then saved each time you visit that domain. We couple that with giving each domain a unique media file folder location so files are commingled and that’s it! Works like a charm.

There are likely other ways to handle but this this worked for me and allows me to keep on using the basic MAMP settings on my Mac.

Steps:

Pass the name of the wp-config file you want to use via URL on the domain you want to use that wp-config on.

Reload the page and make sure all is okay.

You can now revisit this page as normal and the value will be stored in the cookie.