❶ php怎麼辦url中的index.php去掉
為美觀一些,去掉CI默認url中的index.php。分三步操作:
1.打開apache的配置文件,conf/httpd.conf :
LoadMole rewrite_mole moles/mod_rewrite.so,把該行前的#去掉。
搜索 AllowOverride None(配置文件中有多處),看注釋信息,將相關.htaccess的該行信息改為AllowOverride All。
2.在CI的根目錄下,即在index.php,system的同級目錄下,建立.htaccess,直接建立該文件名的不會成功,可以先建立記事本文件,另存為該名的文件即可。內容如下(CI手冊上也有介紹):
RewriteEngine on
RewriteCond $1 !^(index/.php|images|robots/.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
如果文件不是在www的根目錄下,例如我的是:http://localhost/CI/index.php/,第三行需要改寫為RewriteRule ^(.*)$ /CI/index.php/$1 [L]。
另外,我的index.php的同級目錄下還有js文件夾和css文件夾,這些需要過濾除去,第二行需要改寫為:RewriteCond $1 !^(index/.php|images|js|css|robots/.txt)。
3.將CI中配置文件(system/application/config/config.php)中$config['index_page'] = "index.php";將$config['index_page'] = ""; 。
ok,完成。還要記得重啟apache。
❷ ci怎麼去掉index.php
在根目錄添加.htaccess文件。 文件代碼如下: RewriteEngine On RewriteCond %{REQUEST
❸ 求助,如何處理CI自帶的index.php文件
你的目的是想去掉index.php在不同的伺服器下就要用到那二個文件(這二個文件是重寫地址),去掉index.php除了要那二個文件外還要設置$config['index_page'] = "index.php";改成$config['index_page'] = "";在config.php里改,這樣即使用site_url()生成的地址也不會帶index.php另外,如果你的伺服器不支持URI重寫就沒法去掉index.php
❹ 怎麼把中間的index.php 去掉
apache伺服器的話,可以定義.htaccess文件,在apache的httpd.conf配置文件中開啟url重寫功能。
在.htaccess文件中定義重寫規則,網路一下就有的。
如上,去掉index.php
❺ CI框架怎麼去掉隱藏入口文件index.php
呵呵 新手吧
//$config['index_page'] = 'index.php';
$config['index_page'] = '';
改成這樣就可以了 我也在學習
❻ windows下 php+CI+apache 怎麼刪除URL路徑中的index.php
默認情況下,index/index.php/news/article/my_article 你可以很容易的通過 .htaccess 文件來設置一些簡單的規則刪除它。下面是一個例子,使用「negative」方法將非指定內容進行重定向: RewriteEngine on RewriteCond $1 !^(index\.phpimagesrobots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L] 注意:如果你的項目不在根目錄請把上面這一句改為:RewriteRule ^(.*)$ index.php/$1 [L] 在上面的例子中,可以實現任何非 index.php、images 和 robots.txt 的 HTTP 請求都被指向 index.php。 我的終極解決方案 但在實踐中,以上方案僅適用於與運行於Apache環境下的伺服器且並不具有充分的普遍適用性!當CI程序位於非根目錄或位於某些虛擬主機上時,以上解決方案會引起」404錯誤」或」no input file specified」等錯誤.網路參考過相關問題的解放方案後,找到了一種具有通用性的有效刪除URL路徑中index.php的方法,代碼參考如下: index位於根目錄時,你可以在index.php所在的根目錄里新建.htaccess文件並使用以下代碼: RewriteEngine on RewriteCond $1 !^(index\.phprobots\.txt) RewriteRule ^(.*)$ /index.php?/$1 [L] 當index.php不在根目錄時,你可以在index.php所在目錄里新建.htaccess文件並使用以下代碼: RewriteEngine on RewriteCond $1 !^(index\.phpimagesrobots\.txtl) RewriteRule ^(.*)$ /path_to_app/index.php?/$1 [L] 注意把path_to_app換成你的index.php所在文件的目錄.假設你的index.php放在根目錄的tool子文件夾下,你可以這樣寫: RewriteEngine on RewriteCond $1 !^(index\.phpimagesrobots\.txtl) RewriteRule ^(.*)$ /tool/index.php?/$1 [L] 以上方案應該可以解決Apache環境下如何有效刪除URL中index.php的問題,
❼ CI框架如何刪除URL中index.php的終極解決方案
默認情況下,index.php 文件將被包含在你的 URL 中:
example.com/index.php/news/article/my_article
你可以很容易的通過 .htaccess 文件來設置一些簡單的規則刪除它。下面是一個例子,使用「negative」方法將非指定內容進行重定向:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
注意:如果你的項目不在根目錄請把上面這一句改為:RewriteRule ^(.*)$ index.php/$1 [L]
在上面的例子中,可以實現任何非 index.php、images 和 robots.txt 的 HTTP 請求都被指向 index.php。
我的終極解決方案
但在實踐中,以上方案僅適用於與運行於Apache環境下的伺服器且並不具有充分的普遍適用性!當CI程序位於非根目錄或位於某些虛擬主機上時,以上解決方案會引起」404錯誤」或」no input file specified」等錯誤.網路參考過相關問題的解放方案後,找到了一種具有通用性的有效刪除URL路徑中index.php的方法,代碼參考如下:
index位於根目錄時,你可以在index.php所在的根目錄里新建.htaccess文件並使用以下代碼:
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteRule ^(.*)$ /index.php?/$1 [L]
當index.php不在根目錄時,你可以在index.php所在目錄里新建.htaccess文件並使用以下代碼:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txtl)
RewriteRule ^(.*)$ /path_to_app/index.php?/$1 [L]
注意把path_to_app換成你的index.php所在文件的目錄.假設你的index.php放在根目錄的tool子文件夾下,你可以這樣寫:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txtl)
RewriteRule ^(.*)$ /tool/index.php?/$1 [L]
以上方案應該可以解決Apache環境下如何有效刪除URL中index.php的問題,
❽ 在nginx下如何去除ci框架url中的index.php
ci框架默認的url規則中帶有應用的入口文件,例如:
example.com/index.PHP/news/article/my_article
在以上URL中帶有入口文件index.php,這樣的URL規則對搜索引擎來說是不友好的,那麼如何去除這個index.php?
步驟
1 apache環境下:
通過 .htaccess 文件來設置一些簡單的規則刪除它。下面是一個例子,使用「negative」方法將非指定內容進行重定向:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
2 如果項目不在根目錄請把上面這一句改為:RewriteRule ^(.*)$ index.php/$1 [L]
在上面的例子中,可以實現任何非 index.php、images 和 robots.txt 的 HTTP 請求都被指向 index.php。
Nginx環境下:
修改nginx配置文件,在SERVER段中添加如下代碼:
location /{
if (-f $request_filename) {
expires max;
break;
}
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
}
}
❾ phpCI框架 如何去掉默認index.php
下面是去掉index.php的操作
PHP CodeIgniter(CI)去掉 index.php - Langjun - 博客園
設置訪問的默認路徑是在
文件下,找到
$route['default_controller'] = "index"; 默認的為welcome 改為你的訪問index.php之後的參數
我的訪問首頁
遇到類似的問題,你可以去後盾人平台看看的哦,裡面的東西不錯應該能幫你解決一些不明白的問題(❁´◡`❁)*