当前位置:网站首页>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
边栏推荐
- leetcode 241. Different ways to add parentheses design priority for operational expressions (medium)
- IP地址和物理地址有什么区别
- C4D learning notes 2- animation - timeline and time function
- 01tire+链式前向星+dfs+贪心练习题.1
- Unity drawing plug-in = = [support the update of the original atlas]
- Migration and reprint
- 通知Notification使用全解析
- Performance measure of classification model
- 47_Opencv中的轮廓查找 cv::findContours()
- Bidding announcement: Panjin people's Hospital Panjin hospital database maintenance project
猜你喜欢

Shandong old age Expo, 2022 China smart elderly care exhibition, smart elderly care and aging technology exhibition

Numpy -- epidemic data analysis case

Numpy --- basic learning notes

Multiplication in pytorch: mul (), multiply (), matmul (), mm (), MV (), dot ()

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

Odoo集成Plausible埋码监控平台

Numpy -- data cleaning

torch. Numel action

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

分步式监控平台zabbix
随机推荐
TCP framework___ Unity
华东师大团队提出,具有DNA调控电路的卷积神经网络的系统分子实现
47_ Contour lookup in opencv cv:: findcontours()
Sysom case analysis: where is the missing memory| Dragon lizard Technology
【花雕体验】15 尝试搭建Beetle ESP32 C3之Arduino开发环境
AE learning 01: AE complete project summary
How to query the data of a certain day, a certain month, and a certain year in MySQL
Iptables only allows the specified IP address to access the specified port
The inevitable trend of the intelligent development of ankerui power grid is that microcomputer protection devices are used in power systems
js中复选框checkbox如何判定为被选中
hellogolang
A link opens the applet code. After compilation, it is easy to understand
47_Opencv中的轮廓查找 cv::findContours()
Common training data set formats for target tracking
Regular expression string
用手机在通达信上开户靠谱吗?这样炒股有没有什么安全隐患
prometheus api删除某个指定job的所有数据
目标跟踪常见训练数据集格式
2022 the 4th China (Jinan) International Smart elderly care industry exhibition, Shandong old age Expo
Leetcode-136-只出现一次的数(用异或来解答)