#在Apache配置文件中,开启
LoadModule rewrite_module modules/mod_rewrite.so
#同时确保modules文件夹下存在改文件
1.2、开启允许配置
AllowOverride None 配置为 AllowOverride All
2、Yii2配置
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
],
],
3、添加.htaccess文件
#在与index.php同目录的文件夹中新增名为 .htaccess的文件,内容为:
<IfModule rewrite_module>
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
</IfModule>
4、重启Apache
本人亲测可以
因篇幅问题不能全部显示,请点此查看更多更全内容