More perfect to set the error page.
First, prepare an error page error.html, location: thinkphp\template\index\default\error.html, ready to point to all the previous error hints.
Two, empty operation Point
In apps\index\controller\indexbase.php, the "base class" is set _empty
<? PHP /* */namespace app\index\controller;use app\common\controller\base; class Indexbase extends base{ public function _initialize () { parent::_initialize (); } /* * * Empty operation Jump */public function _empty () {// abort (); exception (); Both of these methods are possible }}
Three, NULL controller point
In apps\index\controller\error.php
<? PHP /* */namespace app\index\controller;use App\index\controller; class Error extends indexbase{ public function Index () { abort ();} }
Four, abnormal error point
The index/config.php exception_tmpl parameter.
' Exception_tmpl ' ' TPL ' ' THINK_EXCEPTION.TPL ' //' exception_tmpl ' = ' e:/wamp/www/thinkphp/template/index/default/error.html ',
Note: The address must be an absolute path.
Expand
401,404,500 error Page Customization
Related parameters: Http_exception_template
Manual Address: http://www.kancloud.cn/manual/thinkphp5/163256
Code:
config.php
'http_exception_template'= [ //defines the redirect page address for the 404 error 404= Root_path.config ('Template.view_path'). config ('Index.model_name').'/'. config ('index.default_template').'/404.html', //You can also define other HTTP status 401= Root_path.config ('Template.view_path'). config ('Index.model_name').'/'. config ('index.default_template').'/401.html', ],
Controller call
Abort (404, ' Error message ')
Error.html,404.html page code, you can refer to Thinkphp\thinkphp\tpl\think_exception.tpl
THINKPHP5 Note Seven: Set error page ②