app.php 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. //自定义路由
  3. use think\facade\Route;
  4. // api子域名路由指定
  5. Route::domain('localapi',function () {
  6. Route::rule('/plugin/:plugin', "laytp\library\PluginRoute@execute");
  7. Route::get('captcha/[:config]','\\think\\captcha\\CaptchaController@index');
  8. Route::rule('/:pathInfo', '/api.:pathInfo')->pattern(['pathInfo'=>'[\w\.\/]+']);
  9. Route::miss(function() {
  10. return json([
  11. "code" => 0,
  12. "msg" => '路由不存在',
  13. "data" => new stdClass()
  14. ]);
  15. });
  16. });
  17. // adminapi子域名路由指定
  18. Route::domain('localadminapi',function () {
  19. Route::rule('/plugin/:plugin', "laytp\library\PluginRoute@execute");
  20. Route::get('captcha/[:config]','\\think\\captcha\\CaptchaController@index');
  21. Route::rule('/:pathInfo', '/admin.:pathInfo')->pattern(['pathInfo'=>'[\w\.\/]+']);
  22. Route::miss(function() {
  23. return json([
  24. "code" => 0,
  25. "msg" => '路由不存在',
  26. "data" => new stdClass()
  27. ]);
  28. });
  29. });