yii怎樣去掉index.php

yii去掉index.php的方法:1、開(kāi)啟apache的mod_rewrite模塊,并重啟apache;2、編輯項(xiàng)目中的/config/web.php文件;3、在與index.php文件同級(jí)目錄下添加【.htaccess】文件。

yii怎樣去掉index.php

具體方法:

(推薦教程:php圖文教程

1、開(kāi)啟apache的mod_rewrite模塊

  • 去掉LoadModule rewrite_module modules/mod_rewrite.so前的“#”符號(hào)

    立即學(xué)習(xí)PHP免費(fèi)學(xué)習(xí)筆記(深入)”;

  • 確保DocumentRoot “/Library/WebServer/Documents”中有“AllowOverride All”

  • 重啟apache,命令: sudo apachectl restart

2、在項(xiàng)目中的/config/web.php中添加代碼:

components'=&gt;array(???????????? ??... 'urlManager'?=&gt;?[ ????????????'enablePrettyUrl'?=&gt;?true, ????????????'showScriptName'?=&gt;?false, ????????????'rules'?=&gt;?[ ????????????????'<controller:>/<action:>'=&gt;'<controller>/<action>', ????????????], ????????],??????????? ?)</action></controller></action:></controller:>

視頻教程推薦:php圖文教程

3、在與index.php文件同級(jí)目錄下(/web/)添加文件“.htaccess”,內(nèi)容如下:

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

? 版權(quán)聲明
THE END
喜歡就支持一下吧
點(diǎn)贊11 分享