【发布时间】:2018-04-05 20:38:53
【问题描述】:
我有这样的路线
Route::get('/articles/{article}', 'ArticleController@show');
一切正常,但如果您将 mydomain.com/articles/non-existent 放在文章名称不存在的地方,我会收到内部错误。
为什么不返回 404 或者我如何让它返回 404 或者我如何处理内部错误以显示页面而不会弄乱 404 错误处理?
我目前在我的 Exceptions/Handler.php 中有这个
public function render($request, Exception $exception)
{
if ($this->isHttpException($exception)) {
return response()->view('errors.404', [], 404);
}else{
return response()->view('errors.500', [], 500);
}
}
这总是返回 500 页面,即使它只是一个正常的 404 错误。
感谢您的帮助!
【问题讨论】:
标签: laravel error-handling routing laravel-5.3