Laravel Catch all routes


Example

If you want to catch all routes, then you could use a regular expression as shown:

Route::any('{catchall}', 'CatchAllController@handle')->where('catchall', '.*');

Important: If you have other routes and you don't want for the catch-all to interfere, you should put it in the end. For example:

Catching all routes except already defined

Route::get('login',  'AuthController@login');
Route::get('logout', 'AuthController@logout');
Route::get('home',   'HomeController@home');

// The catch-all will match anything except the previous defined routes.
Route::any('{catchall}', 'CatchAllController@handle')->where('catchall', '.*');