当前位置:网站首页>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 路由简介
- Dotween -- ease function
- hellogolang
- [excelexport], Excel to Lua, JSON, XML development tool
- 平衡二叉树(AVL)
- Laravel constructor and middleware execution order
- What else can an ordinary person do besides working in a factory to make money?
- The differences between exit, exit (0), exit (1), exit ('0 '), exit ('1'), die and return in PHP
- The unity vector rotates at a point
- Laravel5.1 路由 -路由分组
猜你喜欢

Rongyun won the 2022 China Xinchuang digital office portal excellence product award!

AE learning 01: AE complete project summary

统计学习方法——感知机

10 schemes to ensure interface data security

TiDB For PostgreSQL和YugabyteDB在Sysbench上的性能对比

C4D learning notes 2- animation - timeline and time function

平衡二叉树(AVL)

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

Lecturer solicitation order | Apache seatunnel (cultivating) meetup sharing guests are in hot Recruitment!

Apache Doris刚“毕业”:为什么应关注这种SQL数据仓库?
随机推荐
three.js打造酷炫下雪效果
Unity3D_ Class fishing project, control the distance between collision walls to adapt to different models
Strengthen real-time data management, and the British software helps the security construction of the medical insurance platform
C4D learning notes 2- animation - timeline and time function
pycharm 终端部启用虚拟环境
2022山东智慧养老展,适老穿戴设备展,养老展,山东老博会
Regular expression string
Performance measure of classification model
Leetcode-136- number that appears only once (solve with XOR)
laravel构造函数和中间件执行顺序问题
How can laravel get the public path
Xcode Revoke certificate
Step by step monitoring platform ZABBIX
95. (cesium chapter) cesium dynamic monomer-3d building (building)
【HCSD大咖直播】亲授大厂面试秘诀-简要笔记
Application example of infinite list [uigridview]
laravel怎么获取到public路径
深度之眼(七)——矩阵的初等变换(附:数模一些模型的解释)
【Android -- 数据存储】使用 SQLite 存储数据
47_Opencv中的轮廓查找 cv::findContours()