I have a route group that has a parameter prefix like so:
Route::group(array('prefix' => '{country}'), function($router)
{
});
This allows me to filter the information displayed on the website by country, so a user can visit "website.com/uk" and get UK copyright information displayed throughout the website.
I now have a dilemma that I have an admin area which I do not want to be accessed using the country parameter. For instance, if I access "website.com/admin" when I have defined this route:
Route::get('admin', function()
{
return 'You are at the admin panel.';
});
It simply does not work, because it is caught by the country route group. No matter if I place it before or after the group, it is completely ignored. Is there a known workaround for this or am I doing something wrong?
Routes are matched in order, if a match is found then the matching will not continue. As a general rule the more specific a route is the higher it should be.
Route::get('admin', function()
{
return 'You are at the admin panel.';
});
Route::group(array('prefix' => '{country}'), function($country)
{
Route::get('/hello-world', function($country){
return "You are in the {$country} localisation.";
});
});
/admin
will return You are at the admin panel.
/uk/hello-world
will return You are in the uk localisation.
If this doesn't work you must have a problem elsewhere in your application.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community