首次搭建yii项目的时候的路由是没有美化的,访问形式 www.example.com?r=site/index
而要想使用 www.example.com/site/index 的形式访问的话,需要 美化路由
frontend 或者 backend 对应应用下的 main.php 中打开注释的代码
<?php['components' => ['urlManager' => [// 路由开启美化 此为true'enablePrettyUrl' => true,// 访问路由的时候是否带有index.php'showScriptName' => false,'rules' => [// ...],],],]
还没结束,如果是 apache还需要找一份 .htaccess文件
Options +FollowSymLinksIndexIgnore */*RewriteEngine on# if a directory or a file exists, use it directlyRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-d# otherwise forward it to index.phpRewriteRule . index.php
