1.修改xxx/config/main.php文件
'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.在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