之前的TP版本 建立一个空控制:
namespace Home\Controller;
use Think\Controller;
use Org\Util\TPage;
class EmptyController extends CommonController {
//空操作
public function _empty() {
//当前控制器名
$_action = strtolower(CONTROLLER_NAME);
//为空
if (empty($_action)) {
$_action = strtolower(MODULE_NAME);
}
//为空
if (empty($_action)) {
E($this->SYSTEM["empty_1"], "/404.html");
}
直接访问 :http://localhost/test
可以返回 test 不需要 http://localhost/Home/test 这样访问
}
}
TP5版本建立一个
namespace app\index\controller;
use think\Request;
use think\Controller;
class Error extends Controller{
public function _empty(){
//当前控制器名
$_action = Request::instance()->controller();
p($_action);
//首页
if ($_action == "index") {
$_action = Request::instance()->module();
}
//为空
if (empty($_action)) {
$_action = Request::instance()->module();
}
访问 http://localhost/test 是显示 【模块不存在:test】
需要加上模块http://localhost/index/test 才可以显示当前方法?
}
}
求大神 解释一下!谢谢
附件
QQ截图20161018104004.png
( 72.09 KB 下载:44 次 )