当前位置:网站首页>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
边栏推荐
- 谈谈 SAP iRPA Studio 创建的本地项目的云端部署问题
- The differences between exit, exit (0), exit (1), exit ('0 '), exit ('1'), die and return in PHP
- hellogolang
- TCP framework___ Unity
- Common training data set formats for target tracking
- 招标公告:福建省农村信用社联合社数据库审计系统采购项目(重新招标)
- How to implement backspace in shell
- ThinkPHP URL 路由简介
- Logback logging framework third-party jar package is available for free
- 10 schemes to ensure interface data security
猜你喜欢

pycharm 终端部启用虚拟环境

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

Apache Doris刚“毕业”:为什么应关注这种SQL数据仓库?

Mysql database basic operation DQL basic query

Description of vs common shortcut keys

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

SPI master rx time out中断

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

分步式监控平台zabbix

Statistical learning method -- perceptron
随机推荐
分类模型评价标准(performance measure)
喜讯!科蓝SUNDB数据库与鸿数科技隐私数据保护管理软件完成兼容性适配
模仿企业微信会议室选择
Leetcode-231-2的幂
Migration and reprint
Laravel 服务提供者实例教程 —— 创建 Service Provider 测试实例
Iptables only allows the specified IP address to access the specified port
MySQL数据库基本操作-DQL-基本查询
Leetcode-136- number that appears only once (solve with XOR)
[excelexport], Excel to Lua, JSON, XML development tool
three.js打造酷炫下雪效果
Performance measure of classification model
[hcsd celebrity live broadcast] teach the interview tips of big companies in person - brief notes
Laravel constructor and middleware execution order
[flower carving experience] 15 try to build the Arduino development environment of beetle esp32 C3
AE learning 01: AE complete project summary
js中复选框checkbox如何判定为被选中
统计学习方法——感知机
神经网络c语言中的指针是怎么回事
航天宏图信息中标乌鲁木齐某单位数据库系统研发项目