Imagine the scenario where you have multiple subdomains, such as multiple locales for the internalization of your application served as
es.example.test. You don't need to put each of them as a seperate entry to your both homestead config file and the hosts file if all of them will be served from the same application. There is of course an easier way.
Let's assume our application is located within the
~/Code/Example folder and we want to map it to
example.test, furthermore, the ip address assigned to our box is
$ nano ~/Homestead/Homestead.yaml
The most simple Homestead config will be like below.
- map: ~/Code/Example
- map: example.test
Then, ssh into your vagrant box and edit the
nginx.conf of the
$ cd ~/Homestead && vagrant up && vagrant ssh
$ sudo nano /etc/nginx/sites-available/example.test
And just add the wildcard entry to the server_name.
server_name example.test *.example.test
And reload the nginx configuration.
$ sudo service nginx reload
Then on your local machine, add a dnsmasq entry.
$ sudo nano /etc/NetworkManager/dnsmasq.d/local
Just add the entry below.
Finally, restart the network-manager.
$ sudo service network-manager restart
Now everything should be ok. You don't need to add individual entries for each of the subdomains of your application. For instance, both en.example.test and es.example.test will be served without adding a seperate configuration for each.