当前位置:网站首页>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
边栏推荐
- How can laravel get the public path
- Strengthen real-time data management, and the British software helps the security construction of the medical insurance platform
- Is it reliable to open an account on Tongda letter with your mobile phone? Is there any potential safety hazard in such stock speculation
- Bidding announcement: Panjin people's Hospital Panjin hospital database maintenance project
- SysOM 案例解析:消失的内存都去哪了 !| 龙蜥技术
- How to implement backspace in shell
- AE learning 01: AE complete project summary
- Good news! Kelan sundb database and Hongshu technology privacy data protection management software complete compatibility adaptation
- Particle effect for ugui
- 一个普通人除了去工厂上班赚钱,还能干什么工作?
猜你喜欢

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

Logback logging framework third-party jar package is available for free

Leetcode-231-2的幂

AE learning 01: AE complete project summary
![Unity drawing plug-in = = [support the update of the original atlas]](/img/b0/92114ffb1f168a1f27125db46c6797.jpg)
Unity drawing plug-in = = [support the update of the original atlas]

What about the pointer in neural network C language

华东师大团队提出,具有DNA调控电路的卷积神经网络的系统分子实现

模仿企业微信会议室选择

Enterprise log analysis system elk

【Android -- 数据存储】使用 SQLite 存储数据
随机推荐
Shader basic UV operations, translation, rotation, scaling
How to query the data of a certain day, a certain month, and a certain year in MySQL
Eye of depth (VII) -- Elementary Transformation of matrix (attachment: explanation of some mathematical models)
修改配置文件后tidb无法启动
Common training data set formats for target tracking
讲师征集令 | Apache SeaTunnel(Incubating) Meetup 分享嘉宾火热招募中!
Odoo integrated plausible embedded code monitoring platform
Unity的三种单例模式(饿汉,懒汉,MonoBehaviour)
Step by step monitoring platform ZABBIX
121. The best time to buy and sell stocks
招标公告:2022年云南联通gbase数据库维保公开比选项目(第二次)比选公告
Introduction to pyGame games
TiDB For PostgreSQL和YugabyteDB在Sysbench上的性能对比
SPI master RX time out interrupt
分类模型评价标准(performance measure)
iptables只允许指定ip地址访问指定端口
Sysom case analysis: where is the missing memory| Dragon lizard Technology
Odoo集成Plausible埋码监控平台
Continuous creation depends on it!
Logback logging framework third-party jar package is available for free