首頁  >  文章  >  php框架  >  yii怎樣去掉index.php

yii怎樣去掉index.php

王林
王林原創
2020-08-15 15:18:283619瀏覽

yii去掉index.php的方法:1.開啟apache的mod_rewrite模組,並重啟apache;2、編輯專案中的/config/web.php檔;3、在與index.php檔同級目錄下方新增【.htaccess】檔案。

yii怎樣去掉index.php

具體方法:

(推薦教學:php圖文教學

1、開啟apache的mod_rewrite模組

  • 去掉LoadModule rewrite_module modules/mod_rewrite.so前的「#」符號

  • 確保DocumentRoot "/Library/WebServer /Documents"6e3512f89a97c220f19675c12d5a1a4cbb15ed4aadeed04b3991578461de0768中有「AllowOverride All」

  • ##重啟apache,指令: sudo apachectl restart


    #重啟apache,指令: sudo apachectl restart

2、在專案中的/config/web.php中加入程式碼:

components'=>array(            
  ...
'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                '/'=>'/',
            ],
        ],           
 )
(影片教學建議:

php影片教學

###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

以上是yii怎樣去掉index.php的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn