YII2.0 去掉index.php

  1. 在 index.php 同级目录建立 .htaccess 文件 ,设置内容:

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

2. 入口配置文件中
'urlManager' => [
'class' => 'yii\web\UrlManager',
// Disable index.php
'showScriptName' => false,
// Disable r= routes
'enablePrettyUrl' => true,
'rules' => array(

),
],
posted @ 2015-10-25 10:56  Yeah,程序猿  阅读(146)  评论(0)    收藏  举报