我目前正在开展一个laravel项目.我需要将所有错误页面重定向到404页面未找到页面.
public function render($request, Exception $exception)
{
if ($this->isHttpException($exception)) {
switch ($exception->getStatusCode()) {
// not authorized
case '403':
return \Response::view('404',array(),403);
break;
// not found
case '404':
return \Response::view('404',array(),404);
break;
// internal error
case '500':
return \Response::view('404',array(),500);
break;
default:
return $this->renderHttpException($exception);
break;
}
} else {
return parent::render($request, $exception);
}
return parent::render($request, $exception);
}
Run Code Online (Sandbox Code Playgroud)
反正有错误页面重定向到404页面吗?此代码中也未显示验证错误(发生验证错误时重定向到404).我使用的是5.4版.