How to use subdomains as parameters in your routes (or in your web.php file)

October 26, 2018

You can use subdomains in your routes. You can either have certain routes for certain subdomains, or pass the subdomain as a parameter in the routing.

<?php
Route::domain('{account}.example.com')->group(function () {
    Route::get('user/{id}', function ($account, $id) {
        //
    });
});