I use MAMP Pro for my Mac OS localhost WordPress development environment. Lately, I’ve been working with a few WordPress multisite subdomain installs, and I’ve been frustrated without the inability to setup a local Wildcard DNS using the
Hosts > General > Aliases
option. Luckily, I found a work-around to enable Wildcard DNS on my localhost for each Host
I have set. Here’s how I did it:
Follow These Steps
- Open up MAMP Pro
- Go to:
File -> Edit Template -> Apache -> httpd.conf
- Search for this line:
ServerName MAMP_VirtualHost_ServerName_MAMP
- Add this directly below it:
ServerAlias *.MAMP_VirtualHost_ServerName_MAMP
- Restart MAMP.
That’s it, you now have a localhost wildcard DNS setup for your MAMP Pro development environment.
Be aware
This will automatically add a wildcard ServerAlias
to all your MAMP Pro hosts, which you may or may not want depending on your situation.
About the Author
Kevin Leary is a web developer in Boston, MA specializing in enterprise website design and development, online marketing, and conversion optimization.
Hey Kevin,
I came across your article while searching for wildcard DNS entries on MAMP PRO.
I followed your steps above but it doesn't work. I've added a new host – mydomain.com. Added server alias http://www.mydomain.com. I can view my local site fine. But if I try viewing sean.mydomain.com – The page seems to hang forever.
Have you any suggestions to what might be wrong?
I'm running the latest version of MAMP PRO – 2.1.2.
Sean
Kevin, I tried your setup and it didn't work for me. My understanding is that each time we create a site in MAMP PRO it updates our /etc/hosts by adding a new entry. Well this seems to be a limitation, because this file does not accepts wildcards. How did you get around it?
Thanks
Peter
This did not work for me either.
Didn’t work. But I found a workaround for this.. and it worked for me. Here’s how i did it
Just add any subdomain to General>Host>Alias Name. In my case I added any.mydomain.dev, then click save. Then open your terminal and type sudo nano /etc/hosts, look for …
127.0.0.1 any.mydomain.dev –> change it to 127.0.0.1 *.mydomain.dev …
then save it. Now try any subdomain like subdomain.mydomain.dev! Hope that helps!
Thanks Dan Israel, your solution worked for me. Actually, I noticed that I didn’t need to make any change in the hosts file – just adding an alias name for each new site on the multisite network did the trick.