thinkphp 路由参数 域名 miss设置

路由的使用

在route/app.php文件里设置路由


use think\facade\Route;

// rule()
// 还有其他的快捷方式 Route::GET POST PUT DELETE PATCH HEAD OPTIONS ANY
// Route::rule('index/:id', 'Login/index', 'GET|POST')->https();
// Route::get('index/:id', function ($id) {
//     return 'hello,ThinkPHP6!' . $id;
// });

// 参数
// ext 设置路由的后缀 强制路由后缀设置  全局设置后缀 在config/route.php中设置
// Route::rule('index/:id', 'Login/index')->ext('html|shtml|xml');

// denyExt 禁止访问的后缀
// Route::rule('index/:id', 'Login/index')->denyExt('html|shtml|xml|jpg|png');

// https 设置路由的请求类型
// Route::rule('index/:id', 'Login/index', 'GET|POST'); // ->https()

// domain 检测当前域名是否匹配 完整域名或子域名都可以 不匹配不能访问
// Route::rule('index/:id', 'Login/index')->domain('www.tp.cn');

// options 集中设置参数
// Route::rule('index/:id', 'Login/index')->options([
//     'https' => true,
//     'domain' => 'www.tp.cn'
// ]);

// 每个域名下生效不同的路由
// Route::domain('www.tp.cn', function () {
//    Route::rule('index/:id', 'Login/index');
// });
// Route::domain('www.tp2.cn', function () {
//    Route::rule('index/:id', 'Login/index');
// });

// 404 miss路由 找不到地址跳转到404页面
Route::rule('index/:id', 'Login/index');
Route::miss(function () {
    return '404 Not Found';
});
//或者跳转到指定的页面 方法
Route::miss('Login/error');

posted on   完美前端  阅读(135)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示