Unable to load the requested file - CodeIgniter

我与影子孤独终老i 提交于 2019-12-13 15:10:44

问题


I'm trying to include a PHP file called includes.php which is not contained within the normal Views folder. The file contains links to the JS files to be loaded with this particular theme. includes.php resides within the scripts folder:

| assets |
         | themes
                  | theme_name
                               | css
                               | img
                               | scripts
| application
| system

In my controller I'm using $this->load->helper('url') which always works fine, and within the View I'm trying to call the following:

$includes_url = asset_url() . 'themes/' . $theme . '/scripts/includes.php';
$this->load->file($includes_url);

The URL seems correct as when I echo $includes_url the path is fine.

Despite this, I'm getting the error:

An Error Was Encountered
Unable to load the requested file: includes.php

What other issues could there be besides Code Igniter not finding the file with that filepath? Have I missed something obvious?


回答1:


i think you're using .htaccess file with codeigniter which is causing you problem in getting the exact path of the php file you wish to include. rename the word library in the below code with the name of the PARENT folder which contain the include file and then update it with your existing .htaccess file.

RewriteEngine on
RewriteCond $1 !^(index\.php|library|user_guide|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]


来源:https://stackoverflow.com/questions/6665012/unable-to-load-the-requested-file-codeigniter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!