Yii2YII2.0

yii2.0去掉index.php

2016-12-30  本文已影响26人  踏云小子

1.开启apache的mod_rewrite模块

sudo apachectl restart

2.在项目中的/config/web.php中添加代码:

components'=>array(            
  ...
'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
            ],
        ],           
 )

3.在与index.php文件同级目录下(/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
defaults write com.apple.finder AppleShowAllFiles -bool true

再重启电脑,真是蛋疼,妈蛋

over~

上一篇 下一篇

猜你喜欢

热点阅读