【发布时间】:2015-11-18 15:31:12
【问题描述】:
我试图弄清楚如果找不到路线,则显示 404 页面未找到。我遵循了许多教程,但它不起作用。
我在\laravel\resources\views\errors中有404.blade.php
也在 handler.php 中
public function render($request, Exception $e)
{
if ($e instanceof TokenMismatchException) {
// redirect to form an example of how i handle mine
return redirect($request->fullUrl())->with(
'csrf_error',
"Opps! Seems you couldn't submit form for a longtime. Please try again"
);
}
/*if ($e instanceof CustomException) {
return response()->view('errors.404', [], 500);
}*/
if ($e instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException)
return response(view('error.404'), 404);
return parent::render($request, $e);
}
如果我在浏览器中输入错误的 URL,它会返回一个空白页面。我有
'debug' => env('APP_DEBUG', true),
在 app.php 中。
如果找不到路由,谁能帮我显示 404 页面?谢谢。
【问题讨论】:
-
你目前得到了什么?
-
使用中止(404);然后在错误文件夹 404.blade.php 中创建一个页面
-
@mdamia.where 我必须使用 abort(404) ?
-
@aug Post 指定 5.1。那是 4.2 的文档。
标签: php laravel laravel-5.1