There is a neat feature in Laravel called a Fallback Route. This is the route which will handle the request if none of the others can:
Route::fallback(Controller::class);
The fallback method is simply a convenience function which expands to the following:
Route::get('{fallbackPlaceholder}', Controller::class)
->where('fallbackPlaceholder', '.*')
->fallback();
Knowning this we can easily rename the fallbackPlaceholder
parameter by defining our own route and chaining the fallback()
method:
Route::get('{myPlaceholderName}', Controller::class)
->where('myPlaceholderName', '.*)
->fallback();