You should first declare your search route. Since the language segment is a variable segment, it will catch your 'search' as being a language.
Both routes are different, but your variabel route declarations should come after the 'fixed' routes.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi,
I have an issue which I'm stuck for hours trying to resolve and didn't find a proper solution yet.
I have two routes:
"{lang}/{menuLinkSlug}" ,"DefaultTheme\PagesController@_defaultView"
"/search/test", "DefaultTheme\SearchController@index"
As far as I read, laravel is supposed to give priority to last declared route, in my case 'search/test'. However, all my requests are going to {lang}/{menuLinkSlug}. When I change the order, the opposite occurs.
Questions:
Thanks in advance,
Hey -
You should always declare hard-coded routes first, because any wild-card routes would be executed if they're declared before hard-coded routes.
Route::get('/users/{name}', 'SomeController@action');
Route::get('/users/admins', 'SomeController@action'); // never be called as /users/admins matches the pattern /users/{name} and the first route will get executed instead.
Please or to participate in this conversation.