当前位置:网站首页>Set the route and optimize the URL in thinkphp3.2.3
Set the route and optimize the URL in thinkphp3.2.3
2022-07-07 16:21:00 【Full stack programmer webmaster】
demand : When accessing this directory ,http://xx.com/p-412313 To redirect to ( Let's call it that for a moment )http://xx.com/Home/Blog/index/id/412313
It just looks good
My application directory is Application. The module is Home
First step : Know which file and how to handle the route Routing processing in think/Route.class.php
- // Dynamic routing processing
- $routes = C(‘URL_ROUTE_RULES’);
- // var_dump($routes);
- if(!empty($routes)) {
- // dump($routes);
- //array(1) {
- // [“/^p-(\d+)$/”] => string(16) “Blog/index?id=:1”
- //}
- // echo “rount.class.php\n”;
- foreach (routes as rule=>
- if(is_numeric($rule)){
- // Support array(‘rule’,’adddress’,…) Define routes
- rule = array_shift(route);
- }
- … Lots of code , Only identify the location
The second step : Under the configuration file of the project module , Setup profile as follows ( because tp Is to load the configuration file level by level , Convention configuration -> Application configuration -> Mode configuration
Set up -> Debug configuration -> State configuration -> The module configuration -> Extended configuration -> Dynamic configuration , This belongs to module configuration
- <?php
- return array(
- ‘MODULE_ALLOW_LIST’ => array(‘Home’,‘Admin’,‘Common’),
- ‘DEFAULT_MODULE’ => ‘Home’, // Default module
- ‘DEFAULT_CONTROLLER’ => ‘Index’, // Default controller name
- ‘DEFAULT_ACTION’ => ‘index’, // Default operation name
- // Routing rules
- ‘URL_ROUTER_ON’ => TRUE,
- ‘URL_ROUTE_RULES’ => array(
- ‘/^c-(\d+)$/’ => ‘Index/content?id=:1’
- ),
- ‘URL_ROUTER_ON ‘=>true,
- ‘URL_MODEL’ => ‘1’,
- ‘URL_ROUTE_RULES’=>array(
- ‘/^p-(\d+)$/’ => ‘Home/Blog/index?id=:1’,// It means to visit x.com/p-34 What you will visit is x.com/Blog/index/id/34
- ),
- );
Third parts : If you don't set the default module , There will be no p-34 The error of this module . So you need to index.php Set in define(‘BIND_MODULE’,’Home’);
That's it .
explain : If there is no third step . It is normal to open by default, that is .
however
So we operate the third step , The following effects can be achieved :
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/113178.html Link to the original text :https://javaforall.cn
边栏推荐
- Introduction to pyGame games
- 过度依赖补助,大客户收款难,冲刺“国产数据库第一股”的达梦后劲有多足?
- 记一次项目的迁移过程
- Unity drawing plug-in = = [support the update of the original atlas]
- Logback日志框架第三方jar包 免费获取
- Multiplication in pytorch: mul (), multiply (), matmul (), mm (), MV (), dot ()
- What else can an ordinary person do besides working in a factory to make money?
- Laravel 服务提供者实例教程 —— 创建 Service Provider 测试实例
- 华东师大团队提出,具有DNA调控电路的卷积神经网络的系统分子实现
- PHP实现微信小程序人脸识别刷脸登录功能
猜你喜欢
Numpy -- epidemic data analysis case
华东师大团队提出,具有DNA调控电路的卷积神经网络的系统分子实现
Strengthen real-time data management, and the British software helps the security construction of the medical insurance platform
Tragedy caused by deleting the console statement
Wireless sensor networks -- ZigBee and 6LoWPAN
Mysql database basic operation DQL basic query
模仿企业微信会议室选择
95. (cesium chapter) cesium dynamic monomer-3d building (building)
Continuous creation depends on it!
讲师征集令 | Apache SeaTunnel(Incubating) Meetup 分享嘉宾火热招募中!
随机推荐
leetcode 241. Different ways to add parentheses design priority for operational expressions (medium)
js中复选框checkbox如何判定为被选中
Vs tool word highlight with margin
Three. JS introductory learning notes 19: how to import FBX static model
Talk about the cloud deployment of local projects created by SAP IRPA studio
Is it reliable to open an account on Tongda letter with your mobile phone? Is there any potential safety hazard in such stock speculation
121. The best time to buy and sell stocks
招标公告:福建省农村信用社联合社数据库审计系统采购项目(重新招标)
MySQL中, 如何查询某一天, 某一月, 某一年的数据
Excessive dependence on subsidies, difficult collection of key customers, and how strong is the potential to reach the dream of "the first share of domestic databases"?
Bidding announcement: Fujian Rural Credit Union database audit system procurement project (re bidding)
安科瑞电网智能化发展的必然趋势电力系统采用微机保护装置是
AE learning 02: timeline
融云斩获 2022 中国信创数字化办公门户卓越产品奖!
山东老博会,2022中国智慧养老展会,智能化养老、适老科技展
PHP实现执行定时任务的几种思路详解
47_Opencv中的轮廓查找 cv::findContours()
一个普通人除了去工厂上班赚钱,还能干什么工作?
Shader basic UV operations, translation, rotation, scaling
Mysql database basic operation DQL basic query