快被 thinkphp 路由搞死了,求大佬救命

2018-08-02 17:39:07 +08:00
 501691899
分类下的内容可以访问
如: http://baidu.com/chanpin/13-463.html 正常,

但是分类的首页不能,分类首页是 http://baidu.com/chanpin.html

如果分类的首页用 http://baidu.com/home/product/index/id/1.html 地址 是可以访问的

现在的路由这样的
return array(
':l/Tags/:module/:tag/:p' => 'Home/Tags/index',
':l/Tags/:tag/:p' => 'Home/Tags/index',
':l/Tags/:module/:tag' => 'Home/Tags/index',
':l/Tags/:p\d' => 'Home/Tags/index',
':l/Tags/:tag' => 'Home/Tags/index',
':l/Tags' => 'Home/Tags/index',
'Tags/:module/:tag/:p' => 'Home/Tags/index',
'Tags/:tag/:p' => 'Home/Tags/index',
'Tags/:module/:tag' => 'Home/Tags/index',
'Tags/:p\d' => 'Home/Tags/index',
'Tags/:tag' => 'Home/Tags/index',
'Tags' => 'Home/Tags/index',
'/^(zh-cn|en)$/' => 'Index/index?l=:1',
'/^(zh-cn|en)\/([\w^_]+)\/-(\d+)-(\d+)-(\d+).$/' => 'Urlrule/show?l=:1&catdir=:2&catid=:3&id=:4&p=:5&',
'/^([\w^_]+)\/-(\d+)-(\d+)-(\d+).$/' => 'Urlrule/show?catdir=:1&catid=:2&id=:3&p=:4&',
'/^(zh-cn|en)\/([\w^_]+)\/(\d+)-(\d+).$/' => 'Urlrule/show?l=:1&catdir=:2&catid=:3&id=:4&',
'/^([\w^_]+)\/(\d+)-(\d+).$/' => 'Urlrule/show?catdir=:1&catid=:2&id=:3&',
'/^(zh-cn|en)\/([\w^_]+)-(\d+)-(\d+).$/' => 'Urlrule/index?l=:1&catdir=:2&catid=:3&p=:4&',
'/^([\w^_]+)-(\d+)-(\d+).$/' => 'Urlrule/index?catdir=:1&catid=:2&p=:3&',
'/^(zh-cn|en)\/([\w^_]+).$/' => 'Urlrule/index?l=:1&catdir=:2&',
'/^([\w^_]+).$/' => 'Urlrule/index?catdir=:1&'
);

现在伪静态是这样的

RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING} ^(.*)$

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?$1 [QSA,PT,L]

如果我添加伪静态是可以搞定,但是得加几十条,

所以求大佬看看能不能加个路由规则
3551 次点击
所在节点    程序员
12 条回复
cncqw
2018-08-02 18:32:24 +08:00
貌似 v2 的大佬都不用 thinkphp 的,你去 thinkphp 论坛问会好一点
yigemeirenyongde
2018-08-02 20:51:23 +08:00
你这路由好乱
showecho
2018-08-02 21:13:06 +08:00
我用的 tp,表示你这太复杂,设计不当,没见过这么多路由指向同一个方法的。
applesbananas
2018-08-02 22:28:58 +08:00
你可以试试类似 laravel,的 Route 路由写法 oute,需要引入 RouteRoute 类,然后的首页的路由放到分组中的最后,里面坑比较多,可以配合 Posteman 调试路由
zzw1998
2018-08-03 04:00:12 +08:00
laravel,你值得拥有
linpf
2018-08-03 09:00:00 +08:00
TP 党表示,看你写的路由头都晕了。你自己写的太乱,真不是框架的锅。
xfcy
2018-08-03 09:08:55 +08:00
看成了 tp-link😰抱歉打扰了
crist
2018-08-03 10:52:32 +08:00
写的什么鬼路由!
501691899
2018-08-03 11:15:15 +08:00
@showecho 不是我写的,以前托管,现在想搬回来,结果发现程序是个坑
501691899
2018-08-03 11:16:06 +08:00
@crist 我也想知道,以前托管的
501691899
2018-08-03 11:16:48 +08:00
我感觉这个坑,我填不起来了
wukaichao
2018-08-03 11:25:26 +08:00
你把这路由推倒了自己重新写啊,何必在坑上填

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/476357

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX