我使用CMS DEW POWER。当我输入错误的地址时,用户会看到页面404,但服务器返回200.我的notfound.phtml:
<div class="text">
<div class="lblock"><b>Requested URL was not found</b><br>
<br>
When trying to connect following error:<br>
<ul class="list1">
<li>Non-existent URL</li>
</ul>
<br>
One element of the requested URL is incorrect. Possible problems:<br>
<ul class="list1">
<li>Missing or incorrect access protocol (should be "http://" or similar)</li>
<li>No host name</li>
<li>Illegal characters in path</li>
<li>Illegal characters in the hostname, underscores banned</li>
</ul>
</div>
<br>
<br>
<br>
<div class="end"> <br>
</div> <br><br><br>
</div>
我尝试在文档的开头插入以下代码,但它没有帮助。
<?php
header("HTTP/1.0 404 Not Found");
?>
答案 0 :(得分:0)
我解决了我的问题。在 SiteController 中,我的 notfoundAction 看起来像这样:
function notfoundAction() {
$this->view->notfound = 1;
$this->view->section_name = '404';
$this->view->inner_content = $this->view->partial('notfound.phtml');
return $this->page_inner();
}
我添加了HttpResponse:
$this->getResponse()->setHttpResponseCode(404);