Laravel default route to 404 page

前端 未结 5 599
离开以前
离开以前 2021-02-08 08:51

I\'m using Laravel 4 framework and I\'ve defined a whole bunch of routes, now I wonder for all the undefined urls, how to route them to 404 page?

5条回答
  •  臣服心动
    2021-02-08 09:28

    The recommended method for handling errors can be found in the Laravel docs:

    http://laravel.com/docs/4.2/errors#handling-404-errors

    Use the App::missing() function in the start/global.php file in the following manner:

    App::missing(function($exception)
    {
        return Response::view('errors.missing', array(), 404);
    });
    

提交回复
热议问题