1.在config/main.php中添加配置信息

文件位置如图所示(图中展示的是backend下的config,也可以在fronted和common的config中添加)

yii2下的路由重写

配置的代码标准格式如下

yii2下的路由重写

 


'showScriptName' = false, // 禁用 index.php
'enablePrettyUrl' =true, // 启用 URL美化
'suffix' ='.html', // 在这里我们不配置,如果启用后缀,那么你的每个请求都会默认有.html的后缀


2.在web下添加.htaccess文件

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php






相关文章:

  • 2021-08-15
  • 2022-12-23
  • 2021-06-17
  • 2022-12-23
  • 2021-12-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-27
  • 2022-01-08
  • 2022-02-25
  • 2021-05-25
  • 2022-01-14
  • 2021-12-18
  • 2022-12-23
相关资源
相似解决方案