Setting Up Subdomain Routing In Laravel For A Windows Machine.
I am working on a project that requires subdomain routing and fortunately, I use windows and not a mac. Using a mac would have easily made me set up subdomain routing with Valet but if you use a windows machine like me, let me run you through it.
Originally, 'php artisan serve' command runs your website with '127.0.0.1' ip and '8000' port by default but for our this project, we want a 'api.app.test', 'admin.app.test', 'contributor.app.test' subdomain routes for our main domain of 'app.test'.
All you need to do is to run your notepad as an administrator and open C:\Windows\System32\Drivers\etc\hosts file and add new lines containing the IP '127.0.0.1' and a name beside it.
You should also update your .env APP_URL to APP_URL=app.test save the file and restart your apache server.
run this in your project terminal:
$ php artisan serve --host=app.test --port=8001
visit the subdomain routes specified in your routes/web.php file
Please note, windows do not support wildcard entries in the hosts file, you have to specify all the individual subdomains.