Reputation: 155
I have base domain routes and subdomain routes. For example if I request subdomain.example.com/test
it will return me right answer. But if I want to request subdomain.example.com
it will execute code from root domain.
Route::get('/', function() {
// Main
});
Route::get('/path', function() {
// ..
});
Route::group(['domain' => 'subdomain.example.com'], function()
{
Route::get('/', function() {
// How to request this part?
});
Route::get('/test', function() {
// Works
});
}
Upvotes: 1
Views: 1084
Reputation: 180023
Changing the order will help - Laravel keeps the routes in order, and checks them one-by-one, so by moving the subdomain's routes above the main routes they'll get found first and used, with the global routes as fallbacks for other domains.
Route::group(['domain' => 'subdomain.example.com'], function()
{
Route::get('/', function() {
// How to request this part?
});
Route::get('/test', function() {
// Works
});
}
Route::get('/', function() {
// Main
});
Route::get('/path', function() {
// ..
});
Upvotes: 1