It is not necessary to try to add it to the server first. thinkphp itself provides the 404 page processing mechanism. we only need to define an EmptyAction under lib. class. php and implement the following methods:
It is not necessary to try to add it to the server first. thinkphp itself provides the 404 page processing mechanism. we only need to define an EmptyAction under lib. class. php and implement the following methods:
-
-
- Class EmptyAction extends Action {
-
- Function _ empty (){
-
- Header ("HTTP/1.0 404 Not Found ");
-
- $ This-> display ('public: 404 ');
-
- }
-
- // 404
-
- Function index (){
-
- Header ("HTTP/1.0 404 Not Found ");
-
- $ This-> display ('public: 404 ');
-
- }
-
- }
-
- ?>
The preceding code directly defines the empty module and the empty operation to achieve 404 redirection. However, it is important to set the header. Otherwise, the returned status will be 200. this class corresponds to a page template named 404 in the Public Template directory.