How to use custom domains with different TLDs on Laravel Valet

Published on May 19th, 2018

If you use Laravel Valet, a Laravel development environment for Mac minimalists, you have the possibility to set one top-level domain. DnsMasq resolves all domains with that top-level domain to 127.0.0. automatically. But what if there is the need for several different TLDs? Let me show you.

What's the reason behind it

Here is my case. A big project of mine has the requirement to load specific language and therefore project configuration based on the given TLD. To get as near as possible the production environment, I wanted to use real TLDs. And as you know, I like the idea, to use the real domains with a local subdomain prefix. Let's try to achieve that.


Get rid of DnsMasq and ignore it. What I do now is really simple. Use the valet park command in your the directory, where all your sites live.

Naming project folders

Here is the trick:

Use as a project/webpage directory the domain you would use. In my case, I have directories like this:

  • ~/Code/
  • ~/Code/
  • ~/Code/
  • ~/Code/
  • ...

Resolving the domains

The only thing that's still missing is, that these domains are not resolved to localhost. Easy enough. Add it to the /etc/hosts table.

sudo vim /etc/hosts

and add it there.


That's it. Now go to your browser and call one of your domain.


This is a very easy way to use customized domains. I am not sure if it's necessary to add these host entries. I got the hope that this is also with DnsMasq possible, but I didn't find a way to do it, to resolve local.* subdomains to If you know a way, please let me know :)

If you enjoy my articles or you like what I'am talking and twittering about, you should sign up. I will show you everything I know.
I send e-mails very irregularly. Your data is safe with me.