tp3.2版本路由设置

个人摄影作品展示

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)) {undefined


            $url    =   __APP__.'/'.rtrim($url,$depr);


        }else{undefined


            $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){undefined


                  $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);


            //}


        }

————————————————

版权声明:本文为CSDN博主「longzai89757」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。

原文链接:https://blog.csdn.net/longzai89757/article/details/86572026


上一篇: ThinkPHP列表排序数字 下一篇:没有了

评论