nginx下yii2设置路由规则

1. 在配置文件web.php中添加配置代码:

  'urlManager'=>[
    'enablePrettyUrl' => true,
    'showScriptName' => false,
    'rules' => [
      "<controller:\w+>/<action:\w+>/<id:\d+>"=>"<controller>/<action>",
      "<controller:\w+>/<action:\w+>"=>"<controller>/<action>"
    ],
  ],

 

2. 在nginx配置文件中添加配置代码:

  location / {
    try_files $uri $uri/ /index.php?$args;
  }

 

3. 一定要重启nginx。

 

【版权申明】未经博主同意,谢绝转载!(请尊重原创,博主保留追究权) http://www.cnblogs.com/facetwitter/p/6029680.html

posted @ 2016-11-04 11:44  saneim  阅读(3456)  评论(0编辑  收藏  举报