phpciurl
❶ php ci 框架可以吧url中的斜杠換成-
1 修改 apache 的 httpd.conf 文件
#LoadMole rewrite_mole moles/mod_rewrite.so
去掉前面的#
2 找到 你程序目錄下的 .htaccess 文件
內容如下
<IfMole mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfMole>
保存 ,重啟就好了
❷ 關於php ci框架ie瀏覽器路徑問題
<scripttype="text/javascript"src="<?phpechobase_url('/js/homepage.js');?>"></script>
像這樣即可
❸ 在ci框架中如何獲取上一個頁面的url
你可以用php源碼 $_SERVER['HTTP_REFERER']函數獲取上一頁面的url
❹ php CI框架中的 $this->uri->segment(); 是什麼意思啊
獲得URL上的參數
比如:...index.php/controller/index/3
$this->uri->segment(3);就是url上從index.php開始往後數,/劃分,例子上就是得到的3
❺ 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的問題,
❻ 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。
❼ php ci 當用戶在url加個get參數 並且這個get的值不存在時怎麼顯示404
可以在控制器里實現。
通過 $this->input->get() 數據。
判斷get得到的數據 是否存在,如果為空 自己寫個 跳轉函數 跳轉頁面提示404即可。
❽ 在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;
}
}
❾ php的CI框架如何實現非同步調用
在你自定義的類庫中初始化CodeIgniter資源
要你自定義的類庫中訪問CodeIgniter的原始資源,你必須使用 get_instance() 函數.這個函數返回一個CodeIgniter super object.
一般來說在你的控制器函數中你可以通過 $this 調用任何可用的CodeIgniter函數:
$this->load->helper('url');
$this->load->library('session');
$this->config->item('base_url');
//etc.
$this, 只直接作用在你自己的控制器,模型和視圖中.當你在自定義類中想使用CodeIgniter原始類時,你可以這樣做:
首先,定義CodeIgniter對象賦給一個變數:
$CI =& get_instance();
一旦定義某個對象為一個變數,你就可以使用那個變數名 取代 $this:
$CI =& get_instance();
$CI->load->helper('url');
$CI->load->library('session');
$CI->config->item('base_url');
//etc.
注意: 你將注意到get_instance()這個函數通過被引用的方式被傳遞:
$CI =& get_instance();
這十分重要. 通過引用的方式賦給變數將使用原始的 CodeIgniter 對象,而不是創建一個副本。
//------------------------------------------------------------------------------------------------//
我想這也許是你需要的.$CI =& get_instance();之後再用$CI->load->library('session');等方法載入你需要的
❿ 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的問題,