Thinkphp 5.0 How to implement a custom 404 (exception handling) page

Source: Internet
Author: User

404 page is the page that the client returns when browsing the Web page, because the server is unable to provide information properly, or the server is unable to respond and does not know the reason. 404 bearer of the user experience and SEO optimization of the task. 404 pages typically give a user access to a page that does not exist on the site or is deleted, and the server returns a 404 error. If the webmaster does not set 404 pages, there will be dead links, spiders crawling such URLs, is not conducive to search engine included, is a site necessary page.

404 error message is usually the target page is changed or removed, or the client Input page address error after the page display, if the direct display of 404 pages or abnormal error, the user experience is very unfriendly to the visitor, so we need to customize a 404 page (Exception handling page).

Error Exception Page Setup

1. Create an exception-handling class:

* Custom classes need to inherit handle and implement the Render method

2. Set the custom error handling page in the configuration file

* To enable custom error handling pages, you first have to set debug in the config.php file to False, otherwise the custom error page will not work properly.

Make the following configuration in the config.php file

After you have completed the above settings, visit the page that you just

You can see that the custom exception handling page has been implemented.

Two great benefits of setting up 404 pages

1, guide users do not close the site, enhance the user experience.

2, prevent the website to appear dead link.

Of course, you can do more beautiful and featured guide page, this article only shared the thinkphp5.0 how to implement the custom 404 page, welcome more friends attention, communication!

Thinkphp 5.0 How to implement a custom 404 (exception handling) page

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.