Home / Snippets / How to Define Fallback Routes in Laravel 8
How to Define Fallback Routes in Laravel 8 cover

How to Define Fallback Routes in Laravel 8


2 years ago


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.

Route::fallback(function () {
  $message = 'You have hit a fallback page!';

  return view('page.fallback-page', ['message' => $message]);
notion avatar

Ahmad Aziz

Week-end developer currently experimenting with web, mobile, and all things programming.






Support Us

If you like our tutorial, support us by being our Patreon or buy us some coffee ☕️

Post Tutorials

Learn trending tutorials for ReactJs, React Native, VueJS, NextJs, Laravel, Tailwind CSS, and Flutter development.
View Tutorials

Code Components

Collection of Tailwind CSS components for everyone to use. Browse all of the components that's right for your web projects
View Components

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this