On my Laravel Homestead configuration file (Homestead.yaml), I'm defining my domain maps as such:
sites:
- map: ~^(?:www\.)?(?<project>.+)$
to: /home/vagrant/www/\$project/public
Thanks to this, I can visit foo.dev
or www.foo.dev
, umbrella.dev
or www.umbrella.dev
etc., and it always matches appropriate project folder, /foo/public
, /umbrella/public
etc.
I find this very convenient solution, but I found one problem with it. When I inspect $_SERVER
superglobal, I see that it equals to ~^(?:www\.)?(?<project>.+)$
instead of the valid domain after parsing. That's fine most of time, but some projects like Kirby CMS use this value to build URLs.
How can I make SERVER_NAME to be foo.dev
, umbrella.dev
etc.?