如果你使用了多級控制器的話,可以設置controller_auto_search參數開啟自動定位控制器,便于URL訪問,例如首先(xian)在配置(zhi)文件中添加:
'controller_auto_search' => true,
然后定義(yi)控制器如(ru)下:
namespace app\index\controller\one;
use think\Controller;
class Blog extends Controller
{
public function index()
{
return $this->fetch();
}
public function add()
{
return $this->fetch();
}
public function edit($id)
{
return $this->fetch('edit:'.$id);
}
}
我們就(jiu)可以直(zhi)接訪問下面的(de)URL地址了:
http://serverName/index.php/index/one/Blog
