Laravel – Exclude rote from Slug

Last Updated: March 30, 2021

In my web.php file I have the following route

Route::get('/{country}', 'App\Http\Controllers\ServiceController@country')

I do want to exclude codekayak.net/login and codekayak.net/register from that route. You can add the following code.

Route::get('/{country}', 'App\Http\Controllers\ServiceController@country')
    ->where('country', '^((?!login|register).)*$');