php 无法加载请求的文件 - CodeIgniter
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6665012/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unable to load the requested file - CodeIgniter
提问by Joe W
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:
我正在尝试包含一个名为的 PHP 文件includes.php
,该文件不包含在普通的 Views 文件夹中。该文件包含指向要使用此特定主题加载的 JS 文件的链接。includes.php
驻留在scripts
文件夹中:
| 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:
在我的控制器中,我使用$this->load->helper('url')
它总是工作正常,在视图中我试图调用以下内容:
$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.
URL 似乎正确,因为当我回$includes_url
显路径很好时。
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?
除了 Code Igniter 找不到具有该文件路径的文件之外,还有哪些其他问题?我错过了一些明显的东西吗?
采纳答案by Pawan Choudhary
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.
我认为您正在使用带有 codeigniter 的 .htaccess 文件,这会导致您无法获取要包含的 php 文件的确切路径。使用包含包含文件的 PARENT 文件夹的名称重命名以下代码中的词库,然后使用现有的 .htaccess 文件更新它。
RewriteEngine on RewriteCond !^(index\.php|library|user_guide|robots\.txt) RewriteRule ^(.*)$ index.php/ [L]