Thinkphp5笔记八:路由别名Route
2024-08-26 06:32:34
主要作用:隐藏自己的真实路由名称
application/Route.php
使用方法一:
<?php
use think\Route;
Route::alias('home','index/index');
Route::alias('admin','admin/index');
方法二:
<?php return [
'__pattern__' => [
'name' => '\w+',
],
'[hello]' => [
':id' => ['index/hello', ['method' => 'get'], ['id' => '\d+']],
':name' => ['index/hello', ['method' => 'post']],
], '__alias__' => [
'home' => 'index/index',
'admin'=> 'admin/index'
], ];
http://localhost/thinkphp/index.php/home/test 同等与http://localhost/thinkphp/index.php/index/index/test
http://localhost/thinkphp/index.php/admin/edit/ 同等与http://localhost/thinkphp/index.php/admin/index/edit
注释:别名 => ‘模型/控制器’ ( 别名等于模块+控制器)
最新文章
- webrtc中APM(AudioProcessing module)的使用
- TableView与delegate、dataResource
- 控制台telnet连接后无法关闭
- php中json_encode UTF-8中文乱码问题
- shell中&;&;和||的使用方法_转
- Spring配置文件解析--依赖注入
- phpStudy Linux安装集成环境 (CentOS--7)
- vi/vim使用指北 ---- Moving Around in a Hurry
- DOM基础之“寻找”子节点
- Infix expression 计算 without &#39;(&#39; and &#39;)&#39;
- 3.3.2 PCI设备对不可Cache的存储器空间进行DMA读写
- Framework启动过程浅析
- tensorflow(3)可视化,日志,调试
- js原生事件系统与坐标系统
- Saiku关于MDX过滤的使用(九)
- 创建cocoapod静态库发布到网上使用
- python(nmap模块、多线程模块)
- Java线程同步与锁
- Git 执行更改
- 【已解决】wepy中使用分包加载报错