路线不存在时重定向laravel 4

时间:2013-10-05 18:35:34

标签: php laravel laravel-4

我正在使用laravel 4,当我的项目处于生产模式时,我收到“抱歉,找不到您正在寻找的页面。”当我遇到一条不存在的路线......

当我grep我的代码时,它发现在两个地方:

./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());

不,我想指定处理404的路线,但似乎无法找到如何做到这一点......

有人可能会解释为什么它会使用symfony错误处理以及可以找到设置的位置吗?

1 个答案:

答案 0 :(得分:9)

您可以注册一个错误处理程序来处理所有" 404 Not Found"应用程序中的错误,允许您返回自定义404错误页面:

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

Check documentation.

此外,Laravel使用了一些Symphony components来简化其框架的某些核心功能的开发过程,包括路由,响应等等。

相关问题