Local Community

How to Map Multiple Domains to One WordPress Install With SSL

I run a multisite that has multiple domain names pointed at it. For local development I like to replicate the same setup. But Local by Flywheel doesn’t support this out of the box. So here is how to make it work:

Note: This has only been tested for Macs. If you can fill in the differences for a Windows machine do let me know.

Setup a WordPress site like normal

Go to ~/Library/Application Support/Local by Flywheel/routes/ and duplicate the conf file of your site. Edit the server_name block of the duplicated file adding your new domain names like so:

		local.dev *.local.dev
		another-domain.dev *.another-domain.dev;

The generated SSL certificate only includes the root domain and any subdomains of that root domain. We’ll need to generate our own self-signed certificates to include multiple domains. I wrote a script to do that for you. Follow the instructions at https://github.com/kingkool68/generate-ssl-certs-for-local-development Don’t forget to edit options.conf to add the domain names the generated certificate should cover. Take the generated certificate (.crt file) and private key (.key file) and copy them to ~/Library/Application Support/Local by Flywheel/routes/certs

Edit your hosts file to recognize the multiple domains. You can tack them on to the end of the entry created by Local by Flywheel:

Before:	local.dev

After:	local.dev another-domain.dev subdomain.another-domain.dev

Restart your site in the Local by Flywheel control panel.

If everything worked your custom domains should point to your WordPress site and be secured by a single valid SSL certificate.

Hi @clay, is there any news regarding multi-domain support? This feature has been requested for years and IMHO is a fundamental part of many (enterprise) projects that Lightning should definitely support. Playing around with configuration files per project as described here and here: One site, multiple domain is IMHO not an option.

In fact, not supporting multiple domains per project spoils much of the fun Lightning brings.

For example, we have a multisite with ~18 instances spread across two domains. Now, every time I need to download the (anonymized) production database (e.g. to reproduce reported issues), I have to run wp search-replace for each instance that is not on the main domain. This is very annoying and error prone.

Thanks a lot!