How to Map Multiple Domains to One WordPress Install With SSL


#1

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:

server_name
		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:

192.168.94.100	local.dev

After:

192.168.94.100	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.