ThinkPHP入口文件的绑定

我们在index.php文件的同级目录新增一个admin.php入口文件,并绑定Admin模块:

// 绑定Home模块到当前入口文件
define('BIND_MODULE','Admin');
define('APP_PATH','./Application/');
require './ThinkPHP/ThinkPHP.php';

如果你更改了系统默认的变量设置,则需要做对应的模块绑定的变量调整。

绑定模块后,原来的访问地址

http://serverName/index.php/Admin/Index/index

就变成

http://serverName/admin.php/Index/index

同样的方式,我们也可以在入口文件中绑定控制器,例如:

define('BIND_MODULE', 'Home'); // 绑定Home模块到当前入口文件
define('BIND_CONTROLLER','Index'); // 绑定Index控制器到当前入口文件
define('APP_PATH','./Application/');
require './ThinkPHP/ThinkPHP.php';

绑定模块和控制器后,原来的访问地址:

http://serverName/index.php/Home/Index/index

就变成:

http://serverName/home.php/index

猜你喜欢

转载自radzhang.iteye.com/blog/2276300