admin管理员组文章数量:1633775
tp3.2版本路由需要设置两个地方,第一个config.php配置URL_ROUTER_ON开启,URL_ROUTE_RULES路由转换;
第二个tp框架自带的functions中的u函数。
配置设置:
'DEFAULT_MODULE' => 'Home', //默认模块
'URL_MODEL' => '2', //URL模式
'URL_ROUTER_ON' => true, // 是否开启URL路由
'URL_ROUTE_RULES' => array(
'index' => 'Index/index',
'pindex' => 'Product/index',
'about' => 'Index/about',
'network' => 'Network/index',
'contact' => 'Contact/index',
'pindex/:id\d/:productid\d' => 'Product/index/id/:id/productid:productid',
),
tp框架自带的functions中的u函数:
// PATHINFO模式或者兼容URL模式
//这行代码下面修改为这个模式
if(isset($route)) {
$url = __APP__.'/'.rtrim($url,$depr);
}else{
$module = (defined('BIND_MODULE') && BIND_MODULE==$module )? '' : $module;
$url = __APP__.'/'.($module?$module.MODULE_PATHINFO_DEPR:'').implode($depr,array_reverse($var));
//if(strpos($url, "Home/Index/index")!==false){
$url = str_replace("Home/Index/index","index",$url);
$url = str_replace("Home/Product/index","pindex",$url);
$url = str_replace("Home/Index/about","about",$url);
$url = str_replace("Home/Network/index","network",$url);
$url = str_replace("Home/Contact/index","contact",$url);
//$url = str_replace("Home/Product/index","index",$url);
//}
}
版权声明:本文标题:tp3.2版本路由设置 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1729176380a1188770.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论