当前位置:网站首页>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. The best time to buy and sell stocks
- 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
- laravel怎么获取到public路径
- Xcode Revoke certificate
- Logback logging framework third-party jar package is available for free
- Performance comparison of tidb for PostgreSQL and yugabytedb on sysbench
- Bidding announcement: 2022 Yunnan Unicom gbase database maintenance public comparison and selection project (second) comparison and selection announcement
- 【知识小结】PHP使用svn笔记总结
- torch. Numel action
- Mysql database backup script
猜你喜欢
2022 the 4th China (Jinan) International Smart elderly care industry exhibition, Shandong old age Expo
Multiplication in pytorch: mul (), multiply (), matmul (), mm (), MV (), dot ()
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
Power of leetcode-231-2
AE learning 01: AE complete project summary
pycharm 终端部启用虚拟环境
Numpy --- basic learning notes
华东师大团队提出,具有DNA调控电路的卷积神经网络的系统分子实现
分步式监控平台zabbix
Good news! Kelan sundb database and Hongshu technology privacy data protection management software complete compatibility adaptation
随机推荐
Bidding announcement: Fujian Rural Credit Union database audit system procurement project (re bidding)
用手机在通达信上开户靠谱吗?这样炒股有没有什么安全隐患
121. The best time to buy and sell stocks
Laravel constructor and middleware execution order
47_ Contour lookup in opencv cv:: findcontours()
Talk about the cloud deployment of local projects created by SAP IRPA studio
安科瑞电网智能化发展的必然趋势电力系统采用微机保护装置是
C4D learning notes 3- animation - animation rendering process case
121. 买卖股票的最佳时机
laravel post提交数据时显示异常
统计学习方法——感知机
Communication mode between application program and MATLAB
分步式监控平台zabbix
AE learning 01: AE complete project summary
Bidding announcement: Panjin people's Hospital Panjin hospital database maintenance project
Statistical learning method -- perceptron
PyTorch 中的乘法:mul()、multiply()、matmul()、mm()、mv()、dot()
Performance comparison of tidb for PostgreSQL and yugabytedb on sysbench
Unity的三种单例模式(饿汉,懒汉,MonoBehaviour)
Bidding announcement: 2022 Yunnan Unicom gbase database maintenance public comparison and selection project (second) comparison and selection announcement