关于Yii2.0的url路径优化问题(配置虚拟路径)

backend/config/main.php

'urlManager' => [

    'enablePrettyUrl' => true,
    'showScriptName' => false, 
    'enableStrictParsing' => false,
    'suffix' => '.html',
        'rules' => [
            '<controller:\w+>/<id:\d+>' => '<controller>/view',
        ],
],

如果在web文件夹下增加一个.htaccess文件,配置如下:

Options +FollowSymLinks 

IndexIgnore */* 

RewriteEngine on  
# if a directory or a file exists, use it directly 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
 
RewriteRule . index.php

 

posted @ 2017-07-07 17:38  北斜杠  阅读(1476)  评论(0编辑  收藏  举报