In the thinkphp framework, the 404 page is set to only three steps, namely, thinkphp404. In the thinkphp framework, the 404 page is set to only three steps. the thinkphp403854 page is an error message optimized when the system cannot find the requested operation method and the requested controller name. In the thinkphp framework, the 404 page is set to only three steps, and thinkphp404
The 404 page is an error message optimized when the system cannot find the requested operation method or the requested controller name.
How to set the ThinkPHP framework when using the 404 page in many websites? next I will introduce one of the methods as follows:
Step 1:In the thinkphp framework, create an EmptyController. class. php instance in Home/comtroroller. the code is as follows:
<? Phpnamespace HomeController; use ThinkController; class EmptyController extends Controller {// empty operation _ empty () method function _ empty () {header ("HTTP/1.0 404 Not Found "); $ this-> display ("Public: 404");} function index () {header ("HTTP/1.0 404 Not Found"); $ this-> dislay ("Public: 404 ") ;}}?>
Note:Specifically, header ("HTTP/1.0 404 Not Found") defines that this status code is Not 404.
Step 2:In the thinkphp framework, create a public class PublicController. class. php with the following code:
<?phpnamespace HomeController;use ThinkController;class PublicController extends Controller{ function _empty(){ header("Location:/bbs/thinkphp/404.html"); }}?>
Note:In the header ("Location:/bbs/thinkphp/404.html"),/bbs/thinkphp/404.html is the address of your 404houpage, which must correspond to the 404.html page Location.
Step 3:Let all other controllers inherit the PublicController. class. php in step 2, for example:
<?phpnamespace HomeController;// use ThinkController;class IndexController extends PublicController { public function index(){ * * * }}?>
Note:Comment out use ThinkController;
The above is all the content set on the thinkphp 404 page. I hope it will be helpful for you to learn about php programming.
The thinkphp404 404 page is an optimized error message when the system cannot find the requested operation method and the requested controller name ....