当前位置:网站首页>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
边栏推荐
- TCP framework___ Unity
- 分类模型评价标准(performance measure)
- Unity3d click events added to 3D objects in the scene
- Performance comparison of tidb for PostgreSQL and yugabytedb on sysbench
- 航運船公司人工智能AI產品成熟化標准化規模應用,全球港航人工智能/集裝箱人工智能領軍者CIMC中集飛瞳,打造國際航運智能化標杆
- Unity的三种单例模式(饿汉,懒汉,MonoBehaviour)
- 2022山东智慧养老展,适老穿戴设备展,养老展,山东老博会
- There are many ways to realize the pause function in JS
- Sysom case analysis: where is the missing memory| Dragon lizard Technology
- leetcode 241. Different ways to add parentheses design priority for operational expressions (medium)
猜你喜欢

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

AE learning 02: timeline

Eye of depth (VII) -- Elementary Transformation of matrix (attachment: explanation of some mathematical models)

Xingruige database was shortlisted as the "typical solution for information technology application and innovation in Fujian Province in 2021"

2022第四届中国(济南)国际智慧养老产业展览会,山东老博会

L'application à l'échelle de la normalisation mature des produits ai des compagnies maritimes, cimc, leader mondial de l'intelligence artificielle portuaire et maritime / intelligence artificielle des

torch.numel作用

深度之眼(七)——矩阵的初等变换(附:数模一些模型的解释)

记一次项目的迁移过程

统计学习方法——感知机
随机推荐
PHP中exit,exit(0),exit(1),exit(‘0’),exit(‘1’),die,return的区别
How to determine whether the checkbox in JS is selected
记一次项目的迁移过程
Leetcode-136- number that appears only once (solve with XOR)
There are many ways to realize the pause function in JS
What are compiled languages and interpreted languages?
Shandong old age Expo, 2022 China smart elderly care exhibition, smart elderly care and aging technology exhibition
招标公告:2022年云南联通gbase数据库维保公开比选项目(第二次)比选公告
Numpy --- basic learning notes
Leetcode-136-只出现一次的数(用异或来解答)
Excessive dependence on subsidies, difficult collection of key customers, and how strong is the potential to reach the dream of "the first share of domestic databases"?
Three. JS introductory learning notes 19: how to import FBX static model
PHP has its own filtering and escape functions
torch. Numel action
Laravel service provider instance tutorial - create a service provider test instance
Odoo集成Plausible埋码监控平台
Unity的三种单例模式(饿汉,懒汉,MonoBehaviour)
【HCSD大咖直播】亲授大厂面试秘诀-简要笔记
强化实时数据管理,英方软件助力医保平台安全建设
Logback logging framework third-party jar package is available for free