0
votes

I started making the project from scratch and I getting a error and I can't figure out what is it that I'm doing wrong.

I made a directory in the controller folder in which I made a new controller and made a route of it in the routes.php but the thing is I'm getting this error

Not Found

The requested URL /Codeigniter/item was not found on this server.

Apache/2.4.18 (Ubuntu) Server at localhost Port 80

Here is my code

Controller :

  /**
   * Responsible for controlling all the battleplan task logic and management
   *
   * @author gardezi
   */
class Item extends MY_Controller
{


    public function __construct()
    {
        parent::__construct();

    }

    public function index(){
        var_dump("HEllo World");
    }
}

and here is the route

$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;


$route['item'] = 'item';

and the MY_Controller Code is :

<?php
  /**
   * This is the controller responsible for redirecting all the logged out user
   * to login page
   *
   * @author gardezi
   */

  class MY_Controller extends CI_Controller{
      public function __construct() {

          parent::__construct();
      }
  }
1
try like /Codeigniter/index.php/item if its work, then issue with htaccess. stackoverflow.com/questions/38828542/url-hide-using-codeigniter/… - shafiq.rst
@shafiq yeah it worked but it is rerouting me to welcome page it should take me to a blank page and should only show hello world - Gardezi
What do you have in MY_Controller? - TimBrownlaw
@TimBrownlaw I have added the My controller code to - Gardezi
Does the Item and MY_Controller controllers residing in the same folder which you have created inside codeigniter's controllers folder? - sheetal

1 Answers

0
votes

As you described that you have created the sub-folder inside the controllers folder of Codeigniter directory and have created the controllers here, then you must add the sub-folder name while routing the controller as:

$route['item'] = 'subFolderName/item';