CodeIgniter中如何引用靜態檔案的路徑

2022-03-16 09:16:04 字數 613 閱讀 7593

引入外部檔案有幾種方法,這裡列舉兩種僅供參考,好久沒用ci了,拿過來熟悉一下,有不到之處還請莫怪。

第一:ci自帶的base_url來設定,如下:

進入 application\config\config.php檔案,在config.php檔案中設定base_url:

$config['base_url'] = //這裡是你的**根目錄

設定好後 再controller某處

$this->load->helper(『url』),

然後再在view層中具體頁面中引入即可:

然後再在view層中具體頁面中引入即可:

我在.htaccess檔案裡設定(作用是隱藏index.php),如下:

rewriteengine on

rewritecond $1 !^(index\.php|images|js|img|css|robots\.txt) #在這裡寫要排除的資源等

rewriterule ^(.*)$ index.php/$1 [l]我把js,css,img等資源資料夾與system資料夾放在同一級下,然後在js資料夾中建立ajax.js檔案,我在view層中的檔案為index.html。這樣我要引入js時,如下:

到這裡就行了。

CodeIgniter中Router類的兩個方法

file location system core router.php 第乙個 fetch the current method access public return string function fetch method return this method 第二個 fetch the c...

利用CodeIgniter中的Email類發郵件

codeigniter擁有功能強大的email類。以下為利用其傳送郵件的 關於ci的email類的詳情請參考 class welcome extends ci controller 在載入email類之後需要配置email引數。配置完成之後使用 this email initialize confi...

利用CodeIgniter中的Email類發郵件

codeigniter擁有功能強大的email類。以下為利用其傳送郵件的 關於ci的email類的詳情請參考 class welcome extends ci controller 在載入email類之後需要配置email引數。配置完成之後使用 this email initialize confi...