yii 2 美化url
1.修改xxx/config/main.php文件
'urlManager' => [ 'enablePrettyUrl' => true, // 'enableStrictParsing' => true, 'showScriptName' => false, 'rules' => [ '<controller:\w+\-\w+|\w+>/<action:\w+\-\w+|\w+>'=>'<controller>/<action>', '<module:\w+\-\w+|\w+>/<controller:\w+\-\w+|\w+>/<action:\w+\-\w+|\w+>'=>'<module>/<controller>/<action>', '/'=>'user/login', ], ],
2.在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 #otherwise forward it to index.php RewriteRule . index.php
posted on 2018-12-17 21:13 running-fly 阅读(245) 评论(0) 编辑 收藏 举报