在 config/web.php 中添加: ... 'components' => [ ... 'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => [ ], ], .... 在 Nginx 中设置: .... location / { # 如果找不到真实存在的文件,把请求分发至 index.php try_files $uri $uri/ /index.php?$args; } ....