服务器报告不存在页面的 200 状态

Server reports a 200 status for non-existent pages

我使用 CMS DEW POWER。当我输入错误的地址时,用户看到的是 404 页面,但服务器 returns 是 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">&nbsp;<br>



            &nbsp;</div>        <br><br><br>

    </div>

我试图在文档的开头插入以下代码,但没有帮助。

<?php
header("HTTP/1.0 404 Not Found");
?>

我解决了我的问题。在 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);