phpcodeigniterincludecodeigniter-url

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?


Solution

  • 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]