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

时间:2021-11-05 13:37:14

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