Map a custom domain with Laravel Valet

As it turns out, it's easier than you'd expect it to be.

Laravel Valet serves *.dev domains by default. But what if you need to host hack the production domain to your project? As it turns out, it’s easier than you’d expect it to be.

First, add the record for the domain to your /etc/hosts file:

sudo echo '127.0.0.1 my-project.com' >> /etc/hosts

Then, in your parked directory, create a symlink with the domain you want to serve:

$ cd ~/projects/
$ valet park
This directory has been added to Valet's paths.
$ mkdir my-project
# my-project.dev is now served by Valet
$ ln -s my-project my-project.com
# my-project.com is now served by Valet

Valet’s Nginx configuration handles all requests by default, so don’t bother creating a custom Nginx config file. Having it serve your specific domain is only a matter of making sure Valet knows where to find your project directory, given its auto-discovery behavior.