2017-09-04 3 views

답변

0

당신이 컨트롤러

$something = Something::findFirst($id); 
if (!$something) { 
    return $this->response->redirect('/404'); 
} 

에있는 가정 또는 당신은 디스패처 당신은 발송자 클래스 forward() 방법을 사용하려면

$this->dispatcher->forward(
    [ 
     'controller' => 'utils', 
     'action'  => 'notfound', 
    ] 
); 
+0

이 URL은 내가 원하는 것이 아니다 그'/ 404'로 변경됩니다. – XieWilliam

+0

디스패처에서'forward' 메소드를 사용해보십시오. 내 의견을 변경하여 –

0

을 사용하여 다른 행동을 전달할 수 있습니다. 비슷한 문제를 가진

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