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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM