Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to load the requested file - CodeIgniter

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?

like image 304
Joe W Avatar asked Jun 24 '26 21:06

Joe W


1 Answers

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]
like image 124
Pawan Choudhary Avatar answered Jun 26 '26 09:06

Pawan Choudhary



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!