2016-02-19 15:22:01 2865次浏览 1条回答 0 悬赏 10 金钱

我在配置文件的`urlManager`里加了'article' => 'article/index''article_p<page:\d+>' => 'article/index'后,url优化只有'article' => 'article/index'规则有效果,'article_p<page:\d+>' => 'article/index'没效果,是什么问题呢,如果把'article' => 'article/index'去掉,'article_p<page:\d+>' => 'article/index'又可以,感觉他们两个同时针对同一方法是冲突了?这问题怎么解决呢

  • 回答于 2016-02-19 15:58 举报

    URL manager 按照 rules 内规则声明的先后顺序依次检查,找到第一个匹配的规则后就会使用该规则,之后的所有规则,不管是否匹配,都会忽略。

    the URL manager examines the rules in the order they are declared and looks for the first rule that matches the requested URL. The matching rule is then used to parse the URL into a route and its associated parameters.

    URL Rules

    你声明的这两条规则中,

    'article' => 'article/index'
    

    是多余的,因为 indexdefault action, 可以自动识别。

    1 条回复
    回复于 2016-02-24 11:03 回复

    我知道可以自动识别,我就是不想用 article/index.html 这样的url,想用 article.html 这样的url

您需要登录后才可以回答。登录 | 立即注册
tgy3300
见习主管

tgy3300

注册时间:2015-03-20
最后登录:2018-09-12
在线时长:19小时53分
  • 粉丝4
  • 金钱10
  • 威望10
  • 积分300

热门问题