In Laravel, you can make use of "Route::fallback" method to catch any incoming request that matches no route. Since typically any unhandled requests will automatically render the "404" page, having a fallback route inside the routes/web.php allow you to customize and return a custom route.
You can define the fallback route like below. The content of the view is up to your customization.
#routes/web.php
Route::fallback(function () {
$message = 'You have hit a fallback page!';
return view('page.fallback-page', ['message' => $message]);
});
Leave a reply