无法加载请求的文件 - CodeIgniter [英] Unable to load the requested file - CodeIgniter
问题描述
我试图包含一个名为 includes.php
的PHP文件,它不包含在普通的Views文件夹中。该文件包含指向要加载此特定主题的JS文件的链接。 includes.php
位于脚本
文件夹中:
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
在我的控制器中,我使用 $ this-& > helper('url')
它总是工作正常,在视图中我试图调用以下:
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);
这个网址似乎正确,因为我回音 $ 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
除了代码Igniter没有找到文件路径的文件,还有什么其他问题?
What other issues could there be besides Code Igniter not finding the file with that filepath? Have I missed something obvious?
推荐答案
我认为你正在使用带有codeigniter的.htaccess文件,您希望包含的php文件的确切路径。
使用包含include文件的PARENT文件夹的名称重命名以下代码中的单词库,然后使用现有的.htaccess文件更新它。
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]
这篇关于无法加载请求的文件 - CodeIgniter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!