When you want to build your own website, you may have to set a default Controller. The default Controller is the first method that’s called when a user just enters your site domain name like example_site.com


We will learn how to set the default Controller and also create a View for this Controller.


Create a new php file – second.php in Controllers directory and add the following code.



<?php if ( ! defined(‘BASEPATH’)) exit(‘No direct script access allowed’);

class second extends CI_Controller {
public function index()



In the Views directory, create a php file – second.php and add the following code.




            echo “This is the Second Page”;





Open config/routes.php and set $route[‘default_controller’] = second


You can also set the default error page under $route[‘404_override’] = errors/error


Now, refresh your browser.