yii2如何优化URL的路径

来源:互联网 发布:工作日志 软件 编辑:程序博客网 时间:2024/05/28 06:08
// 以下以basic版本为例
1.修改config/web.php
'components' => [     
     #code ...
     'urlManager' => [
    'enablePrettyUrl' => true,     
    'showScriptName' => false,
     ],
#code ...
]

2.在和入口文件相同目录下加入.htaccess文件
.htaccess内容:
RewriteEngine on
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php

0 0
原创粉丝点击