Laravel default route to 404 page

前端 未结 5 600
离开以前
离开以前 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:37

    I've upgraded my laravel 4 codebase to Laravel 5, for anyone who cares:

    App::missing(function($exception) {...});
    

    is NO LONGER AVAILABLE in Laravel 5, in order to return the 404 view for all non-existent routes, try put the following in app/Http/Kernel.php:

    public function handle($request) {
        try {
            return parent::handle($request);
        }
        catch (Exception $e) {
            echo \View::make('frontend_pages.page_404');
            exit;
            // throw $e;
        }
    }
    

提交回复
热议问题