0
id가 없으면 404 페이지를 클라이언트에 응답하고 싶습니다.팔콘에서 404 페이지를 응답하는 방법?
$something = Something::findFirst($id);
if (!$something) {
//response a 404 page
}
어떻게 할 수 있습니까?
id가 없으면 404 페이지를 클라이언트에 응답하고 싶습니다.팔콘에서 404 페이지를 응답하는 방법?
$something = Something::findFirst($id);
if (!$something) {
//response a 404 page
}
어떻게 할 수 있습니까?
당신이 컨트롤러
$something = Something::findFirst($id);
if (!$something) {
return $this->response->redirect('/404');
}
에있는 가정 또는 당신은 디스패처 당신은 발송자 클래스 forward()
방법을 사용하려면
$this->dispatcher->forward(
[
'controller' => 'utils',
'action' => 'notfound',
]
);
을 사용하여 다른 행동을 전달할 수 있습니다. 비슷한 문제를 가진
if ($somethingFailed) {
return $this->dispatcher->forward(['controller' => 'index', 'action' => 'error404']);
}
// Controller method
function error404Action()
{
$this->response->setStatusCode(404, "Not Found");
$this->view->pick('_layouts/error-404');
$this->response->send();
}
질문 : Redirecting to 404 route in PhalconPHP results in Blank Page
이 URL은 내가 원하는 것이 아니다 그'/ 404'로 변경됩니다. – XieWilliam
디스패처에서'forward' 메소드를 사용해보십시오. 내 의견을 변경하여 –