Wildcard subdomains on macOS in MAMP

Imani Manyara
3 min readNov 3, 2021

When working on a web development project that requires a wildcard subdomain setup can be a frustrating task especially if you are on a MacOS + MAMP Pro setup. In this article, I will show you how to solve that problem.

Photo by Gozha Net on Unsplash

While building a project at work that required dynamic subdomains, I found myself in a very frustrating situation. On each new subdomain, I was forced to add a new alias to the website configuration. Uuuurgh!

So is there a solution for that?

By default, MacOS does not allow you to add wildcard subdomains to your /etc/hosts file so you have to look for an alternative solution, and after a bit of research, I found that I could use dnsmasq with some added configuration to the MAMP setup.

Solution

The solution requires two steps; the first step is to set up dnsmasq with .dev or any other domain extension of your choice. dnsmasq will listen to every domain within .dev For example*.something.dev. but also http://dev or stackoverflow.dev Upon proper dnsmasq setup, all .devtraffic will be sent 127.0.0.1 You can do the same with any other extension i.e .local

Step 1:

The first thing to do is to install dnsmasq via brew.

brew install dnsmasq

--

--

Imani Manyara
Imani Manyara

Written by Imani Manyara

Founder @Simtabi. Previously @BBC | Senior Full-stack Software Engineer | Entrepreneur | Global citizen, Innovator, Writer | Seventh Day Adventist

No responses yet