dsjgk330337 2017-06-12 09:36
浏览 18
已采纳

Yii2从规范中删除索引

Because the default action in Yii2 is index, Yii2 redirects http://example.com/sample to SampleController->actionIndex().

Now when I generate the canonical it generates http://example.com/sample/index as the canonical. What I want is http://example.com/sample, so without the /index because that is already obvious and I don't want any visitors (or bots) to see that it's actually going to /index.

I tried to add this rule '<controller>/<action:index>' => '<controller>' to the rules section of the urlManager (frontend/config/main.php).

Also found this for Yii1.1. But it should be easier with Yii2 right?

Any help is appreciated! Thank you and have a great day. Melle Dijkstra

  • 写回答

1条回答 默认 最新

  • dq62957 2017-06-12 09:58
    关注

    I think I've got it working now with the following rule:

    '<controller>' => '<controller>/index'

    Hope this helps anyone having the same situation.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题