Yii2开启enableprettyurl(url美化)无效

最终显示的url格式为:http://localhost/yii2/frontend/web/site/about

在/config/main.php中 ’components‘=>[] 中添加如下代码:

'urlManager' => [
            'enablePrettyUrl' => true,//将?r=site%2Fabout美化为/site/about
            'showScriptName' => false,//隐藏index.php
            'rules' => [
            ],
        ],

还需在index.php入口文件同级的目录下添加.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    
上一篇:安装git 配置邮箱和用户名


下一篇:mysql-front导出数据库字典