1.在main.php文件中开启 urlManager组件
'urlManager' => [ 'enablePrettyUrl' => true, // 'enableStrictParsing' => true, 'showScriptName' => false, 'rules' => [ '<controller:w+-w+|w+>/<action:w+-w+|w+>'=>'<controller>/<action>', '<module:w+-w+|w+>/<controller:w+-w+|w+>/<action:w+-w+|w+>'=>'<module>/<controller>/<action>', '/'=>'user/login', ], ],
2.在backend/web目录下新建.htaccess文件,内容如下
#Options +FollowSymLinks
#IndexIgnore /
RewriteEngine on
#if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#otherwise forward it to index.php
RewriteRule . index.php