当前位置:网站首页>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
边栏推荐
猜你喜欢
SysOM 案例解析:消失的内存都去哪了 !| 龙蜥技术
AE learning 01: AE complete project summary
Vs tool word highlight with margin
统计学习方法——感知机
【Android -- 数据存储】使用 SQLite 存储数据
星瑞格数据库入围“2021年度福建省信息技术应用创新典型解决方案”
航運船公司人工智能AI產品成熟化標准化規模應用,全球港航人工智能/集裝箱人工智能領軍者CIMC中集飛瞳,打造國際航運智能化標杆
Power of leetcode-231-2
Unity3D_ Class fishing project, bullet rebound effect is achieved
强化实时数据管理,英方软件助力医保平台安全建设
随机推荐
There are many ways to realize the pause function in JS
融云斩获 2022 中国信创数字化办公门户卓越产品奖!
PHP实现微信小程序人脸识别刷脸登录功能
Eye of depth (VII) -- Elementary Transformation of matrix (attachment: explanation of some mathematical models)
laravel怎么获取到public路径
Balanced binary tree (AVL)
神经网络c语言中的指针是怎么回事
Shipping companies' AI products are mature, standardized and applied on a large scale. CIMC, the global leader in port and shipping AI / container AI, has built a benchmark for international shipping
Iptables only allows the specified IP address to access the specified port
js中复选框checkbox如何判定为被选中
three.js打造酷炫下雪效果
Talk about the cloud deployment of local projects created by SAP IRPA studio
PHP has its own filtering and escape functions
C4D learning notes 2- animation - timeline and time function
Notification uses full resolution
Plate - forme de surveillance par étapes zabbix
【HCSD大咖直播】亲授大厂面试秘诀-简要笔记
模仿企业微信会议室选择
laravel构造函数和中间件执行顺序问题
C4D learning notes 3- animation - animation rendering process case