Thinkphp itself provides a 404-page processing mechanism, we only need to add a EmptyController.class.php in the controller, and the following methods can be implemented as follows:
<?
Class Emptycontroller extends Controller {
function _empty () {
Header ("http/1.0 404 Not Found");
$this->display (' public:404 ');
}
function index () {
Header ("http/1.0 404 Not Found");
$this->display (' public:404 ');
}
}
?>
The above method is to directly define the empty module and null operation to achieve 404 jump, but note that it is important to set header header, otherwise the returned state is 200, and the class corresponding to the template should have the public folder, the next 404 page template.
All the controller should inherit this controller, the configuration will need to delete runtime files directory, otherwise the effect can not be displayed
Configure thinkphp3.2 404 page