• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cannot Call Method of Default Controller

I know that there is familiar problem like my

But, please read it.

I have default controller:

class Main extends CI_Controller {

function __construct()


public function index()

  $head['title'] = $this->config->item('title');
  $head['base'] = $this->config->item('base_url');
  $head['css'] = $this->config->item('css');
  $head['ga'] = $this->config->item('ga');

  $header['left_title'] = 'left_title';
  $header['right_menu'] = 'right_menu';

  $data['head'] = $this->load->view('head',$head);
  $data['header'] = $this->load->view('header',$header);
  $data['body'] = $this->load->view('home');


public function login()
   // same as the index()



My base url is "http://localhost/sch/". I can call the default controller by clicking this url base "http://localhost/sch/". My application/config/routes.php:

$route['default_controller'] = "main";
$route['404_override'] = '';

$route['login'] = "index.php/main/login";

But i can't call the method login() of default controller by clicking this "http://localhost/sch/login" !

And my index page:
$config['index_page'] = 'index.php';

You should not have 'index.php' in the route. The route is completely independent of using or not using 'index.php' as your index_page.
So remove it and try it again.

I've changed route to:
$route['login'] = "main/login";

But probles still exist Sad

Remove $route['login'] = "main/login";
Test like this http://localhost/index.php/sch/login

Once you know that is working, your need to remove the index.php file by using .htaccess
Here is a guide

Are you using .htaccess?

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.