How do I correctly configure my AMPPS localhost to use subdomains for multisite?

On a Mac this is pretty easy to do, I believe it should be the same on a PC (more or less).

Note: Since Chrome no longer plays with domains ending .dev I tend to set up all my local sites on a subdomain, eg: if the public site is www.example.com I would use dev.example.com.

In AMPPS set up the subdomain, remember to enable SSL if the public site runs over https. For this example I’ll use dev.example.com

Next set up your WordPress Network to run in subdomain mode. Follow the instructions that WordPress gives you. You can, if you wish, add all of your networked sites at this point, but they will not be accessible.

Then open up your host file, on a Mac it is located in.

/private/etc/hosts

On Windows it should be located in.

C:\Windows\System32\Drivers\etc\hosts

AMPPS will have added an entry which looks like this.

127.0.0.1 dev.example.com

Under this add all the subdomains which you wish to have eg:

127.0.0.1 dev.example.com
127.0.0.1 en-gb.dev.example.com
127.0.0.1 de-de.dev.example.com
127.0.0.1 fr-fr.dev.example.com

Next open up the following file

/AMPPS/apache/conf/extra/http-vhosts.conf

I guess on a Windows machine this will be located within the programs directory.

Locate the VirtualHost entry which AMPPS has added for dev.example.com, find the line which reads

ServerAlias dev.example.com

And add a wildcard subdomain to it like so.

ServerAlias dev.example.com *.dev.example.com

If you enabled ssl for the subdomain at the start then you’ll also need to amend the SSL VirtualHost, AMPPS normally places this below the entry you’ve just amended. Once again find:

ServerAlias dev.example.com

replace with.

ServerAlias dev.example.com *.dev.example.com

Now all what is left to do is to restart Apache in AMPPS.

You should now be able to visit both http://en-gb.dev.example.com and https://en-gb.dev.example.com without any problems (apart from the normal security error in Chrome).

Remember if you add more multisite you’ll need to update your host file with the new ones.