Support the ongoing development of Laravel.io →
Requests Architecture

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?

Last updated 3 years ago.
0

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.

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.