tp5路由
路由定义
Route::rule(‘路由表达式’,’路由地址’,’请求类新’,’路由参数(数组)’,’变量规则(数组)’);
如:
1 Route::rule('new/:id','index/News/read','get');
route 目录下的任何路由定义文件都是有效的,默认的路由定义文件是route.php
我们访问:
1 http://serverName/new/5会自动路由到:
1 http://serverName/index/news/read/id/5并且原来的访问地址会自动失效。
快捷方式注册
序号 | |||
---|---|---|---|
1 | GET | GET请求 | get |
2 | POST | POST请求 | post |
3 | PUT | PUT请求 | put |
4 | DELETE | DELETE请求 | delete |
5 | PATCH | PATCH请求 | patch |
6 | * | 任何请求类型 | any |
路由分组
如果路由表达式有多个相同的,则推荐路由分组,格式如下:1
2
3
4
5Route::group('new/product',function (){
Route::get('/by_category','index/News/getRead');
Route::get('/:id','index/News/getCheck',[],['id'=>'\d+']);
Route::get('/recent','index/News/getLook');
});
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Heyiki's Blog!
评论
TwikooLivere