对于配置域名路由; 你可以在你的路由文件中这样设置( 假设你现在有pc端要用www.test.com域名, 手机端要用m.test.com域名的需求)
<?php
//pc端路由
\think\Route::domain('www', [
'messages' => ['admin/index/message', ['ext' => 'html']],
]);
//手机端路由
\think\Route::domain('m', [
'messages' => ['mobile/index/message', ['ext' => 'html']],
]);
//在域名路由中使用资源路由
\think\Route::domain('www', function () {
\think\Route::resource('questionforone', 'admin/QuestionForOne');
});
ps:
域名路由配置: 官网地址(https://www.kancloud.cn/manual/thinkphp5/118039)
资源路由配置: 官网地址(https://www.kancloud.cn/manual/thinkphp5/118035)