路线不存在时重定向laravel 4 [英] redirect when route doesn't exist laravel 4

查看:180
本文介绍了路线不存在时重定向laravel 4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用laravel 4,当我的项目处于生产模式时,我得到抱歉,找不到您要查找的页面".当我碰到一条不存在的路线时...

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...

当我grep我的代码时,可以在两个地方找到它:

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

不,我想指定一个处理404的路由,但似乎找不到解决方法...

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

有人可以解释为什么它使用symfony错误处理以及在哪里可以找到设置吗?

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

推荐答案

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

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');
});

检查文档.

此外,Laravel使用一些 Symphony组件来简化其框架的某些核心功能的开发过程,包括路由,响应和还有很多.

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.

这篇关于路线不存在时重定向laravel 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆