By default, Laravel throws a 404 error when it can't bind the model, but you can change that behavior by passing a closure to the missing method.
1Route::get('/users/{user}', [UsersController::class, 'show'])2 ->missing(function ($parameters) {3 return Redirect::route('users.index');4 });
Tip given by @cosmeescobedo