I have two folders set up for custom routing.
The first is my Admin folder for all things admin.
The second is my App which is where teachers go to manage their stuff.
Here are my routing rules in config/routes.php
...
/**
* Admin Area
*/
$route['admin/(:any)'] = 'admin/$1'; // admin folder
/**
* Teacher Area
*/
$route['app/(:any)'] = 'app/$1'; // app folder
Here is my admin controller, when I go to mysite.com/admin it works
<?php
class Admin extends MX_Controller
{
public function index()
{
// login
if (!$this->session->userdata('is_admin')) {
redirect('admin/users/login');
}
$this->load->model('classes/Class_Model');
$data['classes'] = $this->Class_Model->getClasses();
// load module and view
$data['field'] = $field;
$data['search'] = $search;
$data['module'] = 'admin';
$data['view_file'] = 'admin_cpanel';
$this->load->module('templates');
$this->templates->admin($data);
}
}
Here is my app folder, when I go to mysite.com/app it shows a 403 forbidden error.
<?php
class App extends MX_Controller
{
public function index()
{
// login
if (!$this->session->userdata('is_teacher')) {
redirect('app/users/login');
}
$this->load->model('classes/Class_Model');
$data['classes'] = $this->Class_Model->getClasses();
// load module and view
$data['field'] = $field;
$data['search'] = $search;
$data['module'] = 'app';
$data['view_file'] = 'teacher_cpanel';
$this->load->module('templates');
$this->templates->teachers($data);
}
}
Why is it working fine for the one route but not at all for the other?
The solution is that I named my renamed my Application folder as App already so I could not reuse it as a module folder name.