dul*_*lan 10 routes http-status-code-404 laravel
我正在使用Laravel 4框架,我已经定义了一大堆路由,现在我想知道所有未定义的URL,如何将它们路由到404页面?
未定义的路由Symfony\Component\HttpKernel\Exception\NotFoundHttpException使用App :: error()方法触发您可以在app/start/global.php中处理的异常,如下所示:
/**
* 404 Errors
*/
App::error(function(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException $exception, $code)
{
// handle the exception and show view or redirect to a diff route
return View::make('errors.404');
});
Run Code Online (Sandbox Code Playgroud)
小智 6
可以在Laravel文档中找到推荐的处理错误的方法:
http://laravel.com/docs/4.2/errors#handling-404-errors
以下列方式使用start/global.php文件中的App :: missing()函数:
App::missing(function($exception)
{
return Response::view('errors.missing', array(), 404);
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22841 次 |
| 最近记录: |