This article mainly introduces how to rewrite the ThinkPHP U method so that the page under the route is normal. if you need it, refer to ThinkPHP.
ThinkPHP3.1.3 when routing is enabled, the paging address is not the routing address. because thinkphp3.2.1 code has not been fixed, many people have encountered this problem, this article uses the olcms modification method to solve this problem. thanks to phper jack for his contribution. the specific solution is to modify ThinkPHP functions. php's U method is about 287 rows:
If (! Empty ($ vars) {// add the parameter foreach ($ vars as $ var => $ val) {if (''! = Trim ($ val) $ url. = $ depr. $ var. $ depr. urlencode ($ val );}
Add the following code
/** The next page routing becomes invalid after tp is enabled. page-based URL assembly * // if the route if (C ('URL _ ROUTER_ON ') is enabled ')) {foreach (C ('URL _ ROUTE_RULES ') as $ zhaolg => $ zlig) {// traverse the route if (strstr ('/'. GROUP_NAME. $ url, $ zlig) {// find routing rules from the url $ lg = strstr ($ zhaolg, '/:'); // analysis rules with parameters? If ($ lg) {// if the rule includes the parameter $ tempzlg = str_replace ('/:', '', $ lg ); // take the parameter // dump ($ tempzlg); if ($ tempzlg) {if (C ('app _ SUB_DOMAIN_DEPLOY ') {$ zlgurl = str_replace ($ zlig, $ zhaolg ,'/'. GROUP_NAME. $ url); // replace the url with the routing rule} else {$ zlgurl = str_replace ($ zlig, $ zhaolg, $ url ); // replace the url with the routing rule} // note/s/: c/4/p/_ PAGE _/dump ($ zlgurl ); $ url = str_replace ($ lg. '/'. $ tempzlg, '', $ zlgurl); // replace the routing rule parameter} else {// The analysis rule does not contain the parameter if (C ('app _ SUB_DOMAIN_DEPLOY ')) {$ url = str_replace ($ zlig, $ zhaolg ,'/'. GROUP_NAME. $ url); // replace the url with the routing rule} else {$ url = str_replace ($ zlig, $ zhaolg, $ url ); // replace the url with the routing rule }}}}}
Now the problem has been solved!