yii去掉index.php的方法:1、開(kāi)啟apache的mod_rewrite模塊,并重啟apache;2、編輯項(xiàng)目中的/config/web.php文件;3、在與index.php文件同級(jí)目錄下添加【.htaccess】文件。
具體方法:
(推薦教程: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'=>array(???????????? ??... 'urlManager'?=>?[ ????????????'enablePrettyUrl'?=>?true, ????????????'showScriptName'?=>?false, ????????????'rules'?=>?[ ????????????????'<controller:>/<action:>'=>'<controller>/<action>', ????????????], ????????],??????????? ?)</action></controller></action:></controller:>
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)聲明
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載。
THE END