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

时间:2015-09-14 18:05:05

标签: php http-status-code-404

我使用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">&nbsp;<br>



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

    </div>

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

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

1 个答案:

答案 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);