[英]Zend: 500 error instead of 404
Zend Framework 1中出现404错误的问题。http ://www.url.nl/path/wrong返回404错误(因为/path
部分存在)。 但是,当第一个路径错误时(根目录),它将返回500错误。 因此http://url.nl/wrong返回500。有人遇到过同样的问题吗? 这是我的错误处理程序:
switch ($errors->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
// 404 error -- controller or action not found
$this->getResponse()->setHttpResponseCode(404);
$this->view->message = 'Page not found '.$role;
if (!$role) $this->_helper->layout->setLayout ( 'pages/404' );
else $this->_helper->layout->setLayout ( '404' );
break;
default:
// application error
$this->getResponse()->setHttpResponseCode(500);
$this->view->message = 'Application error';
break;
}
if ($errors->exception instanceof Zend_Acl_Exception) {
// send needed headers...
// prepare log message...
// render info: resource_not_found.phtml
$this->_helper->viewRenderer('error-no-access');
$this->_helper->layout->setLayout ( '403' );
}
编辑:ACL管理器是问题所在,在重定向等中包含一些问题。大多数页面重定向到后端并受到限制,因为普通用户试图访问该页面。
/*if (!$role) $this->_helper->layout->setLayout ( 'pages/404' );
else $this->_helper->layout->setLayout ( '404' );
break;
default:
// application error
$this->getResponse()->setHttpResponseCode(500);
$this->view->message = 'Application error';
break;*/
尝试评论上面的部分(就像我一样)。 这将在文件位置(URL)告诉您实际的问题。 一旦知道了问题,就可以解决。
希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.