404 page Implementation of phpcms v9

Source: Internet
Author: User

In phpcms, if you encounter a topic or content that you do not have, you are prompted that there is no relevant information, but the returned status code is still 200, which is not effective in optimization,

How to implement it is actually simple. The operation steps are as follows:

First, create a page404.php file in the root directory of the website,


[Php]
<? Php
Header ('HTTP/1.1 404 Not found ');
?>
Page 404

<? Php
Header ('HTTP/1.1 404 Not found ');
?>
Page 404

In phpcms/module/content/index. php, find lists and show.


[Php]
If (! $ Catid |! $ Id)
 
Header ('location:/page404.php ');
 
If (! Isset ($ CATEGORYS [$ catid]) | $ CATEGORYS [$ catid] ['type']! = 0)
 
Header ('location:/page404.php ');
 
If (! $ R | $ r ['status']! = 99)
 
Header ('location:/page404.php ');

If (! $ Catid |! $ Id)

Header ('location:/page404.php ');

If (! Isset ($ CATEGORYS [$ catid]) | $ CATEGORYS [$ catid] ['type']! = 0)

Header ('location:/page404.php ');

If (! $ R | $ r ['status']! = 99)

Header ('location:/page404.php ');

In lists:

If (! Isset ($ CATEGORYS [$ catid])

Header ('location:/page404.php ');

In this way, the returned status code is correct.


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.