thinkphp5.3的默认模块控制
thinkphp5.3的默认模块控制
thinkphp5.3的默认模块控制是依据参数$_SERVER[‘PATH_INFO’];
代码如下:
/////////////////////////// 设置模块 ////////////////////////////// $M=['m','u','admin','i']; $H=array_reverse(explode('.',$_SERVER['HTTP_HOST'])); $D=explode('/',preg_replace('/^\/|\..*/','',$_SERVER['PATH_INFO'])); if($D[0]=='public')exit("Not Found"); if(in_array($D[0],$M)){ if(in_array($H[2],$M))exit("Not Found"); }else{ $_SERVER['PATH_INFO']='/'.(in_array($H[2],$M)?$H[2]:'i').$_SERVER['PATH_INFO']; } define('IS_HOST',substr(__DIR__,-1)=='W'); /////////////////////////// 设置模块 //////////////////////////////
原文链接:http://www.fastmvc.com/blog/1246.html