Home  >  Article  >  CMS Tutorial  >  How to configure 404 in phpcms

How to configure 404 in phpcms

尚
Original
2020-01-02 09:45:534000browse

PHPCMS是一款网站管理软件。该软件采用模块化开发,支持多种分类方式,使用它可方便实现个性化网站的设计、开发与维护。它支持众多的程序组合,可轻松实现网站平台迁移,并可广泛满足各种规模的网站需求。

How to configure 404 in phpcms

在phpcms v9系统中设置404错误页的方法:

1、在网站根目录,建一个page404.php文件,内容为:

<?php header(&#39;http/1.1 404 Not found&#39;);  ?>

或:

<?php header( $_SERVER[&#39;SERVER_PROTOCOL&#39;]." 404 Not Found", true, 404 );  ?>

或:

<?php  header( $_ENV[&#39;SERVER_PROTOCOL&#39;]." 404 Not Found", true, 404 );  ?>

2、在函数库中定义404页面。

修改phpcms/libs/functions/global.fnc.php,最后位置,插入:

function page404(){  
    header($_SERVER[&#39;SERVER_PROTOCOL&#39;]." 404 Not Found", true, 404 );  
    require(&#39;page404.php&#39;);  
    exit();  
}

3、在phpcms/module/content/index.php中找到lists和show方法,修改插入:

show方法:

if(!$catid || !$id)   
        page404()
if(!isset($CATEGORYS[$catid]) || $CATEGORYS[$catid][&#39;type&#39;]!=0)  
       page404()
if(!$r || $r[&#39;status&#39;] != 99)   
       page404()

lists方法:

if(!isset($CATEGORYS[$catid])) 
page404()

这样修改,当碰到上面的情况就会返回状态码404。

PHP中文网,大量的免费PHPCMS教程,欢迎在线学习!

The above is the detailed content of How to configure 404 in phpcms. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What is phpsso in phpcms?Next article:What is phpsso in phpcms?