這篇文章主要介紹如何去掉ci的index.php,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
去掉ci的index.php的方法:首先打開apache的配置文件;然后將相關(guān)htaccess的相關(guān)信息改為“AllowOverride All”;接著在CI的根目錄下,建立htaccess;最后重啟apache即可。
去掉CodeIgniter(CI)默認url中的index.php的步驟:
1.打開apache的配置文件,conf/httpd.conf :
LoadModule rewrite_module modules/mod_rewrite.so
把該行前的#去掉。
搜索 AllowOverride None(配置文件中有多處),看注釋信息,將相關(guān).htaccess的該行信息改為:
AllowOverride All
2.在CI的根目錄下,即在index.php,system的同級目錄下,建立.htaccess,直接建立該文件名的不會成功,可以先建立記事本文件,另存為該名的文件即可。內(nèi)容如下(CI手冊上也有介紹):
RewriteEngine on RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L]
如果文件不是在www的根目錄下,例如我的是:
http: //localhost/ci_demo_1/index.php/
第三行需要改寫為
RewriteRule ^(.*)$ /CI/index.php/$1 [L]
另外,我的index.php的同級目錄下還有assets文件夾,這些需要過濾除去,第二行需要改寫為:
RewriteCond $1 !^(index\.php|images|assets|robots\.txt
3.將CI中配置文件(application/config/config.php)中
$config[ 'index_page' ] = "index.php" ;
改成
$config[ 'index_page' ] = "" ;
重啟apache,完成。
=========================================================================================================================
php 框架ci去index.php的方法
網(wǎng)上有很多方法都要引入.htaccess文件,如果是在測試環(huán)境下,動態(tài)和靜態(tài)的文件放到一塊,可能測試會有一定的問題(由于全部定向到index.php),靜態(tài)網(wǎng)頁訪問不了。
這里提供一種方法,只需要修改http.conf文件,
步驟:
1 :在配置虛擬目錄下加入
<Directory /> Options Indexes FollowSymLinks AllowOverride all Order allow,deny Allow from all </Directory> <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^/script/(.*) /script/$1 [L] RewriteRule ^(.*)$ /index.php?/$1 [L] </IfModule>
2 將下面這行前面的;去掉
LoadModule rewrite_module modules/mod_rewrite.so
3 重啟apache就可以了,無需加入.htaccess文件
以上是如何去掉ci的index.php的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
當前名稱:如何去掉ci的index.php-創(chuàng)新互聯(lián)
當前URL:http://aaarwkj.com/article6/gesog.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站內(nèi)鏈、小程序開發(fā)、外貿(mào)網(wǎng)站建設(shè)、品牌網(wǎng)站設(shè)計、虛擬主機、標簽優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容