CodeIgniter Forums
not sure why my controller is getting called - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: not sure why my controller is getting called (/showthread.php?tid=55204)



not sure why my controller is getting called - El Forum - 10-14-2012

[eluser]codeigniterzzz[/eluser]
Here is my route for the controller:

Code:
$route['gotopage'] = 'general/gotopage';

The controller file is located here:

application/controllers/general/gotopage.php

Here is the code in the controller file:

Code:
<?php

if (!defined('BASEPATH'))  
    exit('No direct script access allowed');

class Gotopage extends CI_Controller
{  
    public function __construct()  
    {  
        parent::__construct();  
    }
    
    public function index()
    {  
        this->load->view('index');  
    }
}
?>

for some reason codeigniter is throwing the 404 page not found error.

I have no idea what I'm doing wrong...


not sure why my controller is getting called - El Forum - 10-14-2012

[eluser]nencor[/eluser]
have you create the views for index.php ?


not sure why my controller is getting called - El Forum - 10-14-2012

[eluser]codeigniterzzz[/eluser]
yes i have. and teh file is called index.php and is in the views directory.

application/views/index.php


not sure why my controller is getting called - El Forum - 10-14-2012

[eluser]CroNiX[/eluser]
Your route is saying "if the request is for /gotopage, send it to the general controller/gotopage method".

So, you're sending the request to the "general" controller, which doesn't exist.


not sure why my controller is getting called - El Forum - 10-14-2012

[eluser]codeigniterzzz[/eluser]
ok...so how should i correct my routes, directories, files, class names?


not sure why my controller is getting called - El Forum - 10-16-2012

[eluser]Aken[/eluser]
Your example should be okay - it should find the controller in the subdirectory just fine. Can you access the general/gotopage controller directory (without routes)? Verify that you can do that first.