Nenhuma descrição
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. <?php
  2. /**
  3. * 易优CMS
  4. * ============================================================================
  5. * 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
  6. * 网站地址: http://www.eyoucms.com
  7. * ----------------------------------------------------------------------------
  8. * 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
  9. * ============================================================================
  10. * Author: 小虎哥 <1105415366@qq.com>
  11. * Date: 2018-4-3
  12. */
  13. $home_rewrite = [];
  14. $route = [
  15. '__pattern__' => [
  16. 'tid' => '[\-\w]+',
  17. 'dirname' => '[\-\w]+',
  18. 'aid' => '(.*)',
  19. ],
  20. '__alias__' => [],
  21. '__domain__' => [],
  22. ];
  23. $__pattern__ = $route['__pattern__'];
  24. $globalTpCache = tpCache('global');
  25. config('tpcache', $globalTpCache);
  26. $goto = input('param.goto/s');
  27. $goto = trim($goto, '/');
  28. // 会员中心模板风格
  29. $web_users_tpl_theme = !empty($globalTpCache['web_users_tpl_theme']) ? $globalTpCache['web_users_tpl_theme'] : config('ey_config.web_users_tpl_theme');
  30. // 设置默认模板 users ZMH 2024-01-22
  31. if (empty($web_users_tpl_theme)) {
  32. $web_users_tpl_theme = "users";
  33. }
  34. config('ey_config.web_users_tpl_theme', $web_users_tpl_theme);
  35. // 前台模板风格
  36. $web_tpl_theme = !empty($globalTpCache['web_tpl_theme']) ? $globalTpCache['web_tpl_theme'] : config('ey_config.web_tpl_theme');
  37. if (empty($web_tpl_theme)) {
  38. if (file_exists(ROOT_PATH.'template/default')) {
  39. $web_tpl_theme = 'default';
  40. } else {
  41. $web_tpl_theme = '';
  42. }
  43. } else {
  44. if ('default' == $web_tpl_theme && !file_exists(ROOT_PATH.'template/default')) {
  45. $web_tpl_theme = '';
  46. }
  47. }
  48. config('ey_config.web_tpl_theme', $web_tpl_theme);
  49. !empty($web_tpl_theme) && $web_tpl_theme .= '/';
  50. /*辨识是否代码适配,还是PC与移动的分离模板*/
  51. $num = 0;
  52. $response_type = 0; // 默认是代码适配
  53. $tpldirList = ["template/{$web_tpl_theme}pc/index.htm","template/{$web_tpl_theme}mobile/index.htm"];
  54. foreach ($tpldirList as $key => $val) {
  55. if (file_exists($val)) {
  56. $num++;
  57. if ($num >= 2) {
  58. $response_type = 1; // PC与移动端分离
  59. }
  60. }
  61. }
  62. // 分离式模板的手机端以动态URL访问
  63. $separate_mobile = 0;
  64. if (1 == $response_type && empty($globalTpCache['web_mobile_domain']) && isMobile()) {
  65. $separate_mobile = 1;
  66. }
  67. config('ey_config.response_type', $response_type);
  68. config('ey_config.separate_mobile', $separate_mobile);
  69. /*end*/
  70. // mysql的sql-mode模式参数
  71. $system_sql_mode = !empty($globalTpCache['system_sql_mode']) ? $globalTpCache['system_sql_mode'] : config('ey_config.system_sql_mode');
  72. config('ey_config.system_sql_mode', $system_sql_mode);
  73. // 多语言数量
  74. $system_langnum = !empty($globalTpCache['system_langnum']) ? intval($globalTpCache['system_langnum']) : config('ey_config.system_langnum');
  75. config('ey_config.system_langnum', $system_langnum);
  76. // 前台默认语言
  77. $system_home_default_lang = !empty($globalTpCache['system_home_default_lang']) ? $globalTpCache['system_home_default_lang'] : config('ey_config.system_home_default_lang');
  78. config('ey_config.system_home_default_lang', $system_home_default_lang);
  79. // 是否https链接
  80. $is_https = !empty($globalTpCache['web_is_https']) ? true : config('is_https');
  81. config('is_https', $is_https);
  82. // 前台默认区域
  83. // $site_default_home = !empty($globalTpCache['site_default_home']) ? $globalTpCache['site_default_home'] : config('ey_config.site_default_home');
  84. // config('ey_config.site_default_home', $site_default_home);
  85. // 是否存在问答插件
  86. $is_ask_weapp = false;
  87. if (is_dir('./weapp/Ask/')) {
  88. $is_ask_weapp = true;
  89. }
  90. //是否存在tags插件
  91. $is_tags_weapp = false;
  92. if (is_dir('./weapp/Tags/')) {
  93. $weappList = \think\Db::name('weapp')->where([
  94. 'status' => 1,
  95. ])->cache(true, EYOUCMS_CACHE_TIME, 'weapp')
  96. ->getAllWithIndex('code');
  97. if (!empty($weappList['Tags'])) {
  98. $is_tags_weapp = true;
  99. }
  100. }
  101. $uiset = input('param.uiset/s', 'off');
  102. if ('on' == trim($uiset, '/')) { // 可视化页面必须是兼容模式的URL
  103. config('ey_config.seo_inlet', 0);
  104. config('ey_config.seo_pseudo', 1);
  105. config('ey_config.seo_dynamic_format', 1);
  106. } else {
  107. // URL模式
  108. $seo_pseudo = !empty($globalTpCache['seo_pseudo']) ? intval($globalTpCache['seo_pseudo']) : config('ey_config.seo_pseudo');
  109. $seo_dynamic_format = !empty($globalTpCache['seo_dynamic_format']) ? intval($globalTpCache['seo_dynamic_format']) : config('ey_config.seo_dynamic_format');
  110. // 分离式的手机端以动态URL模式访问
  111. if (1 == $separate_mobile) {
  112. // 当前配置是动态或者静态模式
  113. if (in_array($seo_pseudo, [1,2])) {
  114. $seo_pseudo = 1;
  115. $seo_dynamic_format = 1;
  116. }
  117. }
  118. // URL格式
  119. config('ey_config.seo_pseudo', $seo_pseudo);
  120. config('ey_config.seo_dynamic_format', $seo_dynamic_format);
  121. // 伪静态格式
  122. $seo_rewrite_format = !empty($globalTpCache['seo_rewrite_format']) ? intval($globalTpCache['seo_rewrite_format']) : config('ey_config.seo_rewrite_format');
  123. config('ey_config.seo_rewrite_format', $seo_rewrite_format);
  124. // 是否隐藏入口文件
  125. $seo_inlet = !empty($globalTpCache['seo_inlet']) ? $globalTpCache['seo_inlet'] : config('ey_config.seo_inlet');
  126. config('ey_config.seo_inlet', $seo_inlet);
  127. if (3 == $seo_pseudo) {
  128. $request = request();
  129. $lang_rewrite = $site_rewrite = [];
  130. $lang_rewrite_str = $site_rewrite_str = '';
  131. if (config('city_switch_on')) { // 多城市与多语言只能开启一个,多城市优先级高于多语言
  132. if (stristr($request->baseFile(), 'index.php')) {
  133. $site = input('param.site/s');
  134. if (!empty($site) && $request->subDomain() != $site) {
  135. $site_rewrite_str .= '<site>/';
  136. }
  137. }
  138. if (!empty($site_rewrite_str)) {
  139. $site_rewrite = [
  140. // 首页
  141. $site_rewrite_str.'$' => [
  142. 'home/Index/index',
  143. ['method' => 'get', 'ext' => ''],
  144. 'cache'=>1
  145. ],
  146. ];
  147. }
  148. $lang_rewrite_str = $site_rewrite_str;
  149. }
  150. else { // 多语言
  151. $lang = input('param.lang/s');
  152. if (is_language()) {
  153. if (!stristr($request->baseFile(), 'index.php')) {
  154. if (!empty($lang) && $lang != $system_home_default_lang) {
  155. $lang_rewrite_str = '<lang>/';
  156. }
  157. } else {
  158. if (get_current_lang() != get_default_lang()) {
  159. $lang_rewrite_str .= '<lang>/';
  160. }
  161. }
  162. }
  163. if (!empty($lang_rewrite_str)) {
  164. $lang_rewrite = [
  165. // 首页
  166. $lang_rewrite_str.'$' => [
  167. 'home/Index/index',
  168. ['method' => 'get', 'ext' => ''],
  169. 'cache'=>1
  170. ],
  171. ];
  172. }
  173. }
  174. if (in_array($seo_rewrite_format, [1,3,4])) { // 精简伪静态
  175. $home_rewrite = [
  176. // 会员中心
  177. $lang_rewrite_str.'user$' => [
  178. 'user/Users/login',
  179. ['ext' => ''],
  180. 'cache'=>1
  181. ],
  182. $lang_rewrite_str.'reg$' => [
  183. 'user/Users/reg',
  184. ['ext' => ''],
  185. 'cache'=>1
  186. ],
  187. $lang_rewrite_str.'centre$' => [
  188. 'user/Users/centre',
  189. ['ext' => ''],
  190. 'cache'=>1
  191. ],
  192. $lang_rewrite_str.'user/index$' => [
  193. 'user/Users/index',
  194. ['ext' => ''],
  195. 'cache'=>1
  196. ],
  197. $lang_rewrite_str.'cart$' => [
  198. 'user/Shop/shop_cart_list',
  199. ['ext' => ''],
  200. 'cache'=>1
  201. ],
  202. // 搜索伪静态
  203. $lang_rewrite_str.'sindex$' => [
  204. 'home/Search/index',
  205. ['method' => 'get', 'ext' => ''],
  206. 'cache'=>1
  207. ],
  208. $lang_rewrite_str.'search$' => [
  209. 'home/Search/lists',
  210. ['method' => 'get', 'ext' => 'html'],
  211. 'cache'=>1
  212. ],
  213. ];
  214. if (config('city_switch_on')) {
  215. $lang_rewrite_str_1 = str_replace('<site>/', '', $lang_rewrite_str);
  216. $home_rewrite += [
  217. // 多城市站点主页
  218. $lang_rewrite_str_1.'citysite$' => [
  219. 'home/Citysite/index',
  220. ['method' => 'get', 'ext' => ''],
  221. 'cache'=>1
  222. ],
  223. ];
  224. }
  225. if (false === $is_tags_weapp){
  226. $lang_rewrite_str_1 = str_replace('<site>/', '', $lang_rewrite_str);
  227. $home_rewrite += [
  228. // 标签伪静态
  229. $lang_rewrite_str_1.'tags$' => [
  230. 'home/Tags/index',
  231. ['method' => 'get', 'ext' => ''],
  232. 'cache'=>1
  233. ],
  234. $lang_rewrite_str_1.'tags/<tagid>_<page>$' => [
  235. 'home/Tags/lists',
  236. ['method' => 'get', 'ext' => 'html'],
  237. ['tagid' => '[\d]+', 'page' => '[\d]+'],
  238. 'cache'=>1
  239. ],
  240. $lang_rewrite_str_1.'tags/<tagid>$' => [
  241. 'home/Tags/lists',
  242. ['method' => 'get', 'ext' => 'html'],
  243. ['tagid' => '[\d]+'],
  244. 'cache'=>1
  245. ],
  246. ];
  247. }
  248. if (false === $is_ask_weapp) {
  249. // 问答模型
  250. $home_rewrite += [
  251. $lang_rewrite_str.'ask/list_<type_id>_p<p>$' => [
  252. 'home/Ask/index',
  253. ['method' => 'get', 'ext' => ''],
  254. ['type_id' => '[\d]+', 'p' => '[\d]+'],
  255. 'cache'=>1
  256. ],
  257. $lang_rewrite_str.'ask/list_<is_recom>_<type_id>$' => [
  258. 'home/Ask/index',
  259. ['method' => 'get', 'ext' => ''],
  260. ['is_recom' => '[\d]+', 'type_id' => '[\d]+'],
  261. 'cache'=>1
  262. ],
  263. $lang_rewrite_str.'ask/list_<type_id>$' => [
  264. 'home/Ask/index',
  265. ['method' => 'get', 'ext' => ''],
  266. ['type_id' => '[\d]+'],
  267. 'cache'=>1
  268. ],
  269. $lang_rewrite_str.'ask$' => [
  270. 'home/Ask/index',
  271. ['method' => 'get', 'ext' => ''],
  272. 'cache'=>1
  273. ],
  274. $lang_rewrite_str.'ask/view_<ask_id>$' => [
  275. 'home/Ask/details',
  276. ['method' => 'get', 'ext' => 'html'],
  277. ['ask_id' => '[\d]+'],
  278. 'cache'=>1
  279. ],
  280. ];
  281. }
  282. $home_rewrite += [
  283. // 列表页 - 分页
  284. $lang_rewrite_str.'<tid>/list_<typeid>_<page>$' => [
  285. 'home/Lists/index',
  286. ['method' => 'get', 'ext' => ''],
  287. ['tid' => $__pattern__['tid'], 'typeid' => '[\d]+', 'page' => '[\d]+'],
  288. 'cache'=>1
  289. ],
  290. // 列表页
  291. $lang_rewrite_str.'<tid>$' => [
  292. 'home/Lists/index',
  293. ['method' => 'get', 'ext' => ''],
  294. ['tid' => $__pattern__['tid']],
  295. 'cache'=>1
  296. ],
  297. // 内容页
  298. $lang_rewrite_str.'<dirname>/<aid>$' => [
  299. 'home/View/index',
  300. ['method' => 'get', 'ext' => 'html'],
  301. ['dirname' => $__pattern__['dirname'], 'aid' => $__pattern__['aid']],
  302. 'cache'=>1
  303. ],
  304. ];
  305. if ($seo_rewrite_format == 4) { // 父目录/当前目录/
  306. $arctype_list = get_all_arctype();
  307. foreach ($arctype_list as $key=>$val){
  308. $parent_dir = ""; //$val['dirname']."/";
  309. if (!empty($val['parent_id'])) {
  310. $parent_dir = get_all_parent_dirpath($val['parent_id'],$arctype_list,$parent_dir);
  311. } else {
  312. $parent_dir = get_all_parent_dirpath($val['id'],$arctype_list,$parent_dir);
  313. }
  314. $dirname = trim(str_ireplace("/", "-", $parent_dir),"-");
  315. if(!empty($dirname)){
  316. $home_rewrite += [
  317. // 列表页 - 分页
  318. $lang_rewrite_str.$parent_dir.'<tid>/list_<typeid>_<page>$' => [
  319. 'home/Lists/index?'.$dirname,
  320. ['method' => 'get', 'ext' => ''],
  321. ['tid' => $__pattern__['tid'], 'typeid' => '[\d]+', 'page' => '[\d]+'],
  322. 'cache'=>1
  323. ],
  324. // 列表页
  325. $lang_rewrite_str.$parent_dir.'<tid>$' => [
  326. 'home/Lists/index?'.$dirname,
  327. ['method' => 'get', 'ext' => ''],
  328. ['tid' => $__pattern__['tid']],
  329. 'cache'=>1
  330. ],
  331. // 内容页
  332. $lang_rewrite_str.$parent_dir.'<dirname>/<aid>$' => [
  333. 'home/View/index?'.$dirname,
  334. ['method' => 'get', 'ext' => 'html'],
  335. ['dirname' => $__pattern__['dirname'], 'aid' => $__pattern__['aid']],
  336. 'cache'=>1
  337. ],
  338. ];
  339. }
  340. }
  341. }
  342. } else {
  343. $home_rewrite = [
  344. // 会员中心
  345. $lang_rewrite_str.'Users/login$' => [
  346. 'user/Users/login',
  347. ['ext' => 'html'],
  348. 'cache'=>1
  349. ],
  350. $lang_rewrite_str.'Users/reg$' => [
  351. 'user/Users/reg',
  352. ['ext' => 'html'],
  353. 'cache'=>1
  354. ],
  355. $lang_rewrite_str.'Users/centre$' => [
  356. 'user/Users/centre',
  357. ['ext' => 'html'],
  358. 'cache'=>1
  359. ],
  360. $lang_rewrite_str.'Users/index$' => [
  361. 'user/Users/index',
  362. ['ext' => 'html'],
  363. 'cache'=>1
  364. ],
  365. $lang_rewrite_str.'Users/cart$' => [
  366. 'user/Shop/shop_cart_list',
  367. ['ext' => 'html'],
  368. 'cache'=>1
  369. ],
  370. // 文章模型伪静态
  371. $lang_rewrite_str.'article/<tid>/list_<typeid>_<page>$' => [
  372. 'home/Article/lists',
  373. ['method' => 'get', 'ext' => 'html'],
  374. ['tid' => $__pattern__['tid'], 'typeid' => '[\d]+', 'page' => '[\d]+'],
  375. 'cache'=>1
  376. ],
  377. $lang_rewrite_str.'article/<tid>$' => [
  378. 'home/Article/lists',
  379. ['method' => 'get', 'ext' => 'html'],
  380. ['tid' => $__pattern__['tid']],
  381. 'cache'=>1
  382. ],
  383. $lang_rewrite_str.'article/<dirname>/<aid>$' => [
  384. 'home/Article/view',
  385. ['method' => 'get', 'ext' => 'html'],
  386. ['dirname' => $__pattern__['dirname'], 'aid' => $__pattern__['aid']],
  387. 'cache'=>1
  388. ],
  389. // 产品模型伪静态
  390. $lang_rewrite_str.'product/<tid>/list_<typeid>_<page>$' => [
  391. 'home/Product/lists',
  392. ['method' => 'get', 'ext' => 'html'],
  393. ['tid' => $__pattern__['tid'], 'typeid' => '[\d]+', 'page' => '[\d]+'],
  394. 'cache'=>1
  395. ],
  396. $lang_rewrite_str.'product/<tid>$' => [
  397. 'home/Product/lists',
  398. ['method' => 'get', 'ext' => 'html'],
  399. ['tid' => $__pattern__['tid']],
  400. 'cache'=>1
  401. ],
  402. $lang_rewrite_str.'product/<dirname>/<aid>$' => [
  403. 'home/Product/view',
  404. ['method' => 'get', 'ext' => 'html'],
  405. ['dirname' => $__pattern__['dirname'], 'aid' => $__pattern__['aid']],
  406. 'cache'=>1
  407. ],
  408. // 图集模型伪静态
  409. $lang_rewrite_str.'images/<tid>/list_<typeid>_<page>$' => [
  410. 'home/Images/lists',
  411. ['method' => 'get', 'ext' => 'html'],
  412. ['tid' => $__pattern__['tid'], 'typeid' => '[\d]+', 'page' => '[\d]+'],
  413. 'cache'=>1
  414. ],
  415. $lang_rewrite_str.'images/<tid>$' => [
  416. 'home/Images/lists',
  417. ['method' => 'get', 'ext' => 'html'],
  418. ['tid' => $__pattern__['tid']],
  419. 'cache'=>1
  420. ],
  421. $lang_rewrite_str.'images/<dirname>/<aid>$' => [
  422. 'home/Images/view',
  423. ['method' => 'get', 'ext' => 'html'],
  424. ['dirname' => $__pattern__['dirname'], 'aid' => $__pattern__['aid']],
  425. 'cache'=>1
  426. ],
  427. // 下载模型伪静态
  428. $lang_rewrite_str.'download/<tid>/list_<typeid>_<page>$' => [
  429. 'home/Download/lists',
  430. ['method' => 'get', 'ext' => 'html'],
  431. ['tid' => $__pattern__['tid'], 'typeid' => '[\d]+', 'page' => '[\d]+'],
  432. 'cache'=>1
  433. ],
  434. $lang_rewrite_str.'download/<tid>$' => [
  435. 'home/Download/lists',
  436. ['method' => 'get', 'ext' => 'html'],
  437. ['tid' => $__pattern__['tid']],
  438. 'cache'=>1
  439. ],
  440. $lang_rewrite_str.'download/<dirname>/<aid>$' => [
  441. 'home/Download/view',
  442. ['method' => 'get', 'ext' => 'html'],
  443. ['dirname' => $__pattern__['dirname'], 'aid' => $__pattern__['aid']],
  444. 'cache'=>1
  445. ],
  446. // 视频模型伪静态
  447. $lang_rewrite_str.'media/<tid>/list_<typeid>_<page>$' => [
  448. 'home/Media/lists',
  449. ['method' => 'get', 'ext' => 'html'],
  450. ['tid' => $__pattern__['tid'], 'typeid' => '[\d]+', 'page' => '[\d]+'],
  451. 'cache'=>1
  452. ],
  453. $lang_rewrite_str.'media/<tid>$' => [
  454. 'home/Media/lists',
  455. ['method' => 'get', 'ext' => 'html'],
  456. ['tid' => $__pattern__['tid']],
  457. 'cache'=>1
  458. ],
  459. $lang_rewrite_str.'media/<dirname>/<aid>$' => [
  460. 'home/Media/view',
  461. ['method' => 'get', 'ext' => 'html'],
  462. ['dirname' => $__pattern__['dirname'], 'aid' => $__pattern__['aid']],
  463. 'cache'=>1
  464. ],
  465. // 专题模型伪静态
  466. $lang_rewrite_str.'special/<tid>/list_<typeid>_<page>$' => [
  467. 'home/Special/lists',
  468. ['method' => 'get', 'ext' => 'html'],
  469. ['tid' => $__pattern__['tid'], 'typeid' => '[\d]+', 'page' => '[\d]+'],
  470. 'cache'=>1
  471. ],
  472. $lang_rewrite_str.'special/<tid>$' => [
  473. 'home/Special/lists',
  474. ['method' => 'get', 'ext' => 'html'],
  475. ['tid' => $__pattern__['tid']],
  476. 'cache'=>1
  477. ],
  478. $lang_rewrite_str.'special/<dirname>/<aid>$' => [
  479. 'home/Special/view',
  480. ['method' => 'get', 'ext' => 'html'],
  481. ['dirname' => $__pattern__['dirname'], 'aid' => $__pattern__['aid']],
  482. 'cache'=>1
  483. ],
  484. // 单页模型伪静态
  485. $lang_rewrite_str.'single/<tid>$' => [
  486. 'home/Single/lists',
  487. ['method' => 'get', 'ext' => 'html'],
  488. ['tid' => $__pattern__['tid']],
  489. 'cache'=>1
  490. ],
  491. // 搜索伪静态
  492. $lang_rewrite_str.'sindex$' => [
  493. 'home/Search/index',
  494. ['method' => 'get', 'ext' => ''],
  495. 'cache'=>1
  496. ],
  497. $lang_rewrite_str.'search$' => [
  498. 'home/Search/lists',
  499. ['method' => 'get', 'ext' => 'html'],
  500. 'cache'=>1
  501. ],
  502. // 留言模型
  503. $lang_rewrite_str.'guestbook/<tid>$' => [
  504. 'home/Guestbook/lists',
  505. ['method' => 'get', 'ext' => 'html'],
  506. ['tid' => $__pattern__['tid']],
  507. 'cache'=>1
  508. ],
  509. ];
  510. if (config('city_switch_on')) {
  511. $lang_rewrite_str_1 = str_replace('<site>/', '', $lang_rewrite_str);
  512. $home_rewrite += [
  513. // 多城市站点主页
  514. $lang_rewrite_str_1.'citysite$' => [
  515. 'home/Citysite/index',
  516. ['method' => 'get', 'ext' => ''],
  517. 'cache'=>1
  518. ],
  519. ];
  520. }
  521. if (false === $is_tags_weapp){
  522. $lang_rewrite_str_1 = str_replace('<site>/', '', $lang_rewrite_str);
  523. $home_rewrite += [
  524. // 标签伪静态
  525. $lang_rewrite_str_1.'tags$' => [
  526. 'home/Tags/index',
  527. ['method' => 'get', 'ext' => ''],
  528. 'cache'=>1
  529. ],
  530. $lang_rewrite_str_1.'tags/<tagid>_<page>$' => [
  531. 'home/Tags/lists',
  532. ['method' => 'get', 'ext' => 'html'],
  533. ['tagid' => '[\d]+', 'page' => '[\d]+'],
  534. 'cache'=>1
  535. ],
  536. $lang_rewrite_str_1.'tags/<tagid>$' => [
  537. 'home/Tags/lists',
  538. ['method' => 'get', 'ext' => 'html'],
  539. ['tagid' => '[\d]+'],
  540. 'cache'=>1
  541. ],
  542. ];
  543. }
  544. if (false === $is_ask_weapp) {
  545. // 问答模型
  546. $home_rewrite += [
  547. $lang_rewrite_str.'ask/list_<type_id>_p<p>$' => [
  548. 'home/Ask/index',
  549. ['method' => 'get', 'ext' => ''],
  550. ['type_id' => '[\d]+', 'p' => '[\d]+'],
  551. 'cache'=>1
  552. ],
  553. $lang_rewrite_str.'ask/list_<is_recom>_<type_id>$' => [
  554. 'home/Ask/index',
  555. ['method' => 'get', 'ext' => ''],
  556. ['is_recom' => '[\d]+', 'type_id' => '[\d]+'],
  557. 'cache'=>1
  558. ],
  559. $lang_rewrite_str.'ask/list_<type_id>$' => [
  560. 'home/Ask/index',
  561. ['method' => 'get', 'ext' => ''],
  562. ['type_id' => '[\d]+'],
  563. 'cache'=>1
  564. ],
  565. $lang_rewrite_str.'ask$' => [
  566. 'home/Ask/index',
  567. ['method' => 'get', 'ext' => ''],
  568. 'cache'=>1
  569. ],
  570. $lang_rewrite_str.'ask/view_<ask_id>$' => [
  571. 'home/Ask/details',
  572. ['method' => 'get', 'ext' => 'html'],
  573. ['ask_id' => '[\d]+'],
  574. 'cache'=>1
  575. ],
  576. ];
  577. }
  578. /*自定义模型*/
  579. $cacheKey = "application_route_channeltype";
  580. $channeltype_row = \think\Cache::get($cacheKey);
  581. if (empty($channeltype_row)) {
  582. $channeltype_row = \think\Db::name('channeltype')->field('nid,ctl_name')
  583. ->where([
  584. 'ifsystem' => 0,
  585. ])
  586. ->select();
  587. \think\Cache::set($cacheKey, $channeltype_row, EYOUCMS_CACHE_TIME, "channeltype");
  588. }
  589. foreach ($channeltype_row as $value) {
  590. $home_rewrite += [
  591. $lang_rewrite_str.$value['nid'].'/<tid>/list_<typeid>_<page>$' => [
  592. 'home/'.$value['ctl_name'].'/lists',
  593. ['method' => 'get', 'ext' => 'html'],
  594. ['tid' => $__pattern__['tid'], 'typeid' => '[\d]+', 'page' => '[\d]+'],
  595. 'cache'=>1
  596. ],
  597. $lang_rewrite_str.$value['nid'].'/<tid>$' => [
  598. 'home/'.$value['ctl_name'].'/lists',
  599. ['method' => 'get', 'ext' => 'html'],
  600. ['tid' => $__pattern__['tid']],
  601. 'cache'=>1
  602. ],
  603. $lang_rewrite_str.$value['nid'].'/<dirname>/<aid>$' => [
  604. 'home/'.$value['ctl_name'].'/view',
  605. ['method' => 'get', 'ext' => 'html'],
  606. ['dirname' => $__pattern__['dirname'], 'aid' => $__pattern__['aid']],
  607. 'cache'=>1
  608. ],
  609. ];
  610. }
  611. /*--end*/
  612. }
  613. $home_rewrite = array_merge($lang_rewrite, $site_rewrite, $home_rewrite);
  614. }
  615. else if (2 == $seo_pseudo) {
  616. $lang_rewrite_str = $site_rewrite_str = '';
  617. $home_rewrite = [];
  618. if (false === $is_ask_weapp) {
  619. // 问答模型
  620. $home_rewrite += [
  621. $lang_rewrite_str.'ask/list_<type_id>_p<p>$' => [
  622. 'home/Ask/index',
  623. ['method' => 'get', 'ext' => ''],
  624. ['type_id' => '[\d]+', 'p' => '[\d]+'],
  625. 'cache'=>1
  626. ],
  627. $lang_rewrite_str.'ask/list_<is_recom>_<type_id>$' => [
  628. 'home/Ask/index',
  629. ['method' => 'get', 'ext' => ''],
  630. ['is_recom' => '[\d]+', 'type_id' => '[\d]+'],
  631. 'cache'=>1
  632. ],
  633. $lang_rewrite_str.'ask/list_<type_id>$' => [
  634. 'home/Ask/index',
  635. ['method' => 'get', 'ext' => ''],
  636. ['type_id' => '[\d]+'],
  637. 'cache'=>1
  638. ],
  639. $lang_rewrite_str.'ask$' => [
  640. 'home/Ask/index',
  641. ['method' => 'get', 'ext' => ''],
  642. 'cache'=>1
  643. ],
  644. $lang_rewrite_str.'ask/view_<ask_id>$' => [
  645. 'home/Ask/details',
  646. ['method' => 'get', 'ext' => 'html'],
  647. ['ask_id' => '[\d]+'],
  648. 'cache'=>1
  649. ],
  650. ];
  651. }
  652. }
  653. /*插件模块路由*/
  654. $weapp_route_file = 'plugins/route.php';
  655. if (file_exists(APP_PATH.$weapp_route_file)) {
  656. $weapp_route = include_once $weapp_route_file;
  657. $route = array_merge($weapp_route, $route);
  658. }
  659. /*--end*/
  660. /* 扩展路由 ZMH 2024-01-23 */
  661. $route_ext_file = "route_ext.php";
  662. if (file_exists(APP_PATH.$route_ext_file)) {
  663. $route_ext = include_once $route_ext_file;
  664. // $route = array_merge($route_ext, $route);
  665. set_route_ext();
  666. }
  667. }
  668. $route = array_merge($route, $home_rewrite);
  669. // var_dump($route);
  670. return $route;