Is it possible I just need to update my first route to be grouped by domain as well?
I currently have it
Route::get('/', function() { return 'Hello from my main site!'; });
Route::group(array('domain' => 'crm.laravel.dev'), function() { Route::get('/', function() { return 'Hello from my subdomain!'; }); });
Would changing it to this help?
Route::group(array('domain' => 'laravel.dev'), function() { Route::get('/', function() { return 'Hello from my main site!'; }); });
Route::group(array('domain' => 'crm.laravel.dev'), function() { Route::get('/', function() { return 'Hello from my subdomain!'; }); });
Routes are ran one by one from top to bottom. The higher a route is the higher precedence it has.
A /
route will match /
on any domain (by default routes don't care about domain, only the path) therefore if you place your /
route at the top it will match on crm.laravel.dev/
and not go any further. Place your subdomain specific route at the top:
// IF the domain is crm.laravel.dev
Route::group(array('domain' => 'crm.laravel.dev'), function()
{
// THEN match a GET request to /
Route::get('/', function()
{
return 'Hello from my subdomain!';
});
});
// match a GET request to / on ANY domain
Route::get('/', function()
{
return 'Hello from my main site!';
});
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community