redirect when route doesn't exist laravel 4

冷暖自知 提交于 2019-12-24 01:45:20

问题


I'm using laravel 4 and when i have my project in production mode, i get "Sorry, the page you are looking for could not be found." when i hit a non existing route...

When i grep my code it's found in two places:

./vendor/symfony/debug/Symfony/Component/Debug/ExceptionHandler.php:129:                $title = 'Sorry, the page you are looking for could not be found.';
./vendor/symfony/debug/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php:52:        $this->assertContains('Sorry, the page you are looking for could not be found.', $response->getContent());

No i would like to specify a route to handle 404's, but can't seem to find how to do this...

And the can someone maybe explain why it's using symfony error handling and where setting for that can be found?


回答1:


You may register an error handler that handles all "404 Not Found" errors in your application, allowing you to return custom 404 error pages:

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

Check documentation.

Also, Laravel uses some Symphony components to simplify the development process of some core functionality of it's framework, including routing, response and many more.



来源:https://stackoverflow.com/questions/19201305/redirect-when-route-doesnt-exist-laravel-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!