当前位置:网站首页>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
边栏推荐
- ThinkPHP URL 路由简介
- 分步式監控平臺zabbix
- 01tire+链式前向星+dfs+贪心练习题.1
- Unity drawing plug-in = = [support the update of the original atlas]
- 招标公告:盘锦市人民医院盘锦医院数据库维保项目
- 【知识小结】PHP使用svn笔记总结
- Numpy --- basic learning notes
- C4D learning notes 2- animation - timeline and time function
- Continuous creation depends on it!
- How to determine whether the checkbox in JS is selected
猜你喜欢

Sysom case analysis: where is the missing memory| Dragon lizard Technology

The unity vector rotates at a point

95.(cesium篇)cesium动态单体化-3D建筑物(楼栋)

删除 console 语句引发的惨案

SysOM 案例解析:消失的内存都去哪了 !| 龙蜥技术

Plate - forme de surveillance par étapes zabbix

山东老博会,2022中国智慧养老展会,智能化养老、适老科技展

Xcode Revoke certificate

记一次项目的迁移过程
通知Notification使用全解析
随机推荐
Three singleton modes of unity (hungry man, lazy man, monobehavior)
Three. JS introductory learning notes 18: how to export JSON files with Blender
How to query the data of a certain day, a certain month, and a certain year in MySQL
招标公告:盘锦市人民医院盘锦医院数据库维保项目
What are compiled languages and interpreted languages?
How to implement backspace in shell
Lecturer solicitation order | Apache seatunnel (cultivating) meetup sharing guests are in hot Recruitment!
一个普通人除了去工厂上班赚钱,还能干什么工作?
How to determine whether the checkbox in JS is selected
招标公告:福建省农村信用社联合社数据库审计系统采购项目(重新招标)
121. 买卖股票的最佳时机
MySQL数据库基本操作-DQL-基本查询
markdown公式编辑教程
There are many ways to realize the pause function in JS
Migration and reprint
讲师征集令 | Apache SeaTunnel(Incubating) Meetup 分享嘉宾火热招募中!
Shader_ Animation sequence frame
PHP中exit,exit(0),exit(1),exit(‘0’),exit(‘1’),die,return的区别
hellogolang
Balanced binary tree (AVL)