Let's say I have the following:
Route::group(array('domain' => array('admin.example.com')), function() { ... }); Route::group(array('domain' => array('app.example.com')), function() { ... }); Route::group(array('domain' => array('dev.app.example.com')), function() { ... });
Is there any way to have multiple domains share a routing group? Something like:
Route::group(array('domain' => array('dev.app.example.com','app.example.com')), function() { ... });
A network domain is an administrative grouping of multiple private computer networks or local hosts within the same infrastructure. Domains can be identified using a domain name; domains which need to be accessible from the public Internet can be assigned a globally unique name within the Domain Name System (DNS).
Route Groups is an essential feature in Laravel, which allows you to group all the routes. Routes Groups are beneficial when you want to apply the attributes to all the routes. If you use route groups, you do not have to apply the attributes individually to each route; this avoids duplication.
php and Modules/Media/backendRoutes. php files.
by laravelrecipies. Subdomain routing is the same as routing prefixing, but it's scoped by subdomain instead of route prefix. There are two primary uses for this. First, you may want to present different sections of the application (or entirely different applications) to different subdomains.
Laravel does not seem to support this.
I'm not sure why I didn't think of this sooner, but I guess one solution would be to just declare the routes in a separate function as pass it to both route groups.
Route::group(array('domain' => 'admin.example.com'), function() { ... }); $appRoutes = function() { Route::get('/',function(){ ... }); }; Route::group(array('domain' => 'app.example.com'), $appRoutes); Route::group(array('domain' => 'dev.app.example.com'), $appRoutes);
I'm not sure if there is any significant performance impact to this solution.
Laravel 5.1
Route::pattern('subdomain', '(dev.app|app)'); Route::group(['domain' => '{subdomain}.example.com'], function () { ... });
Route::pattern('subdomain', '(dev.app|app)'); Route::pattern('domain', '(example.com|example.dev)'); Route::group(['domain' => '{subdomain}.{domain}'], function () { ... });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With