当前位置:网站首页>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
边栏推荐
- 121. 买卖股票的最佳时机
- 2022山东智慧养老展,适老穿戴设备展,养老展,山东老博会
- Unity的三种单例模式(饿汉,懒汉,MonoBehaviour)
- Shader_ Animation sequence frame
- Asyncio concept and usage
- IP地址和物理地址有什么区别
- 【Android -- 数据存储】使用 SQLite 存储数据
- Apache Doris刚“毕业”:为什么应关注这种SQL数据仓库?
- Unity3D_ Class fishing project, control the distance between collision walls to adapt to different models
- 喜讯!科蓝SUNDB数据库与鸿数科技隐私数据保护管理软件完成兼容性适配
猜你喜欢
![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]

Odoo集成Plausible埋码监控平台

航運船公司人工智能AI產品成熟化標准化規模應用,全球港航人工智能/集裝箱人工智能領軍者CIMC中集飛瞳,打造國際航運智能化標杆

Leetcode-231-2的幂

Strengthen real-time data management, and the British software helps the security construction of the medical insurance platform

Three. JS introductory learning notes 19: how to import FBX static model

Power of leetcode-231-2

Numpy -- epidemic data analysis case

What about the pointer in neural network C language

pycharm 终端部启用虚拟环境
随机推荐
一个普通人除了去工厂上班赚钱,还能干什么工作?
95.(cesium篇)cesium动态单体化-3D建筑物(楼栋)
AE learning 01: AE complete project summary
Statistical learning method -- perceptron
ThinkPHP URL 路由简介
markdown公式编辑教程
【花雕体验】15 尝试搭建Beetle ESP32 C3之Arduino开发环境
Migration and reprint
U3D_ Infinite Bessel curve
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
121. The best time to buy and sell stocks
删除 console 语句引发的惨案
模仿企业微信会议室选择
[excelexport], Excel to Lua, JSON, XML development tool
华东师大团队提出,具有DNA调控电路的卷积神经网络的系统分子实现
How does geojson data merge the boundaries of regions?
Laravel 服务提供者实例教程 —— 创建 Service Provider 测试实例
强化实时数据管理,英方软件助力医保平台安全建设
融云斩获 2022 中国信创数字化办公门户卓越产品奖!
laravel构造函数和中间件执行顺序问题