logo

How to route based on the requested domain

Useful if you serve multiple sites out of the same Laravel app

Joel Clermont
Joel Clermont
2025-11-07

The Laravel docs have great information on how to set up routing based on subdomains.

But recently someone asked if we could do the same with main domains instead of subdomains, and whether we could serve the same route with different content based on the domain.

In today's video, I show how to do this using easily with two small changes to my routes file, and a little local setup for the domain.

Watch Now (3 min)

And after watching, don't forget to subscribe to our YouTube channel, so you don't miss future videos.

Here to help,

Joel

P.S. Want a friendly, low-noise place to ask your Laravel questions? Check out the Mastering Laravel community. I hope to see you inside.

Toss a coin in the jar if you found this helpful.
Want a tip like this in your inbox every weekday? Sign up below 👇🏼
email
No spam. Only real-world advice you can use.