Error: A default route has not been specified in the routing file in CI 3.0

11,131

CodeIgniter 3 requires that your classes are named in a Ucfirst manner and the filenames must match the class names.

Therefore, you need to rename your 'login.php' to 'Login.php', as well as change the class declaration to class Login extends CI_Controller.

Share:
11,131
user3651476
Author by

user3651476

Updated on June 05, 2022

Comments

  • user3651476
    user3651476 almost 2 years

    I have successfully run the test webpage in my local machine and it works! But when I uploaded it to the production server (iPage), I got this error:

    An Error Was Encountered
    Unable to determine what should be displayed. A default route has not been specified in the routing file.

    I have here the .htacess file:

     RewriteEngine On
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteCond $1 !^(index\.php|assets|img|bg|robots\.txt)
     RewriteRule ^(.*)$ index.php?/$1 [L] 
    

    Outside the application folder.

    and in my routes.php:

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

    and in my config.php:

    $config['base_url'] = 'http://example.com/System';
    $config['uri_protocol'] = 'REQUEST_URI';
    $config['enable_query_strings'] = TRUE;
    

    I have login.php inside controller folder with the ff codes:

     defined('BASEPATH') OR exit('No direct script access allowed');
    
    class login extends CI_Controller {
        function __construct() {
            parent::__construct();
            $this->load->model('login_model');
            /* enable session */
            $this->load->library('session');
        }
    
     public function index()
        {
            if ( ! file_exists(APPPATH.'/views/index.php'))
            {
                /* Whoops, we don't have a page for that! */
                   show_404();
    
            }
    
            $this->load->view('index'); 
           $this->load->view('templates/footer');   
    
       }    
    

    Am I missing or did something wrong?

  • user3651476
    user3651476 almost 9 years
    Yes, inside my controller i have login.php
  • Abdulla Nilam
    Abdulla Nilam almost 9 years
    check file inside and base url too
  • Abdulla Nilam
    Abdulla Nilam almost 9 years
    login should be Login
  • user3651476
    user3651476 almost 9 years
    class login extends CI_Controller {} my class name here is small. so my file name should be small caps too, right?
  • Abdulla Nilam
    Abdulla Nilam almost 9 years
    noo. its ok change this class Login extends CI_Controller
  • user3651476
    user3651476 almost 9 years
    when i tried to upload a new CI 3.0 files, i got this. Please se link. bellanueskincare.com/POS
  • Abdulla Nilam
    Abdulla Nilam almost 9 years
    change login to Login inside controller
  • user3651476
    user3651476 almost 9 years
    bellanueskincare.com/System/login still an error page, changing base_url = '' and login class name to Login
  • Abdulla Nilam
    Abdulla Nilam almost 9 years
    remove baseurl function in config.php
  • user3651476
    user3651476 almost 9 years
    you want me to remove/comment this line ? $config['base_url'] = '';
  • Abdulla Nilam
    Abdulla Nilam almost 9 years
    No men. $config['base_url'] = ''; should be empty. and $config['index_page'] = ''; also empty
  • user3651476
    user3651476 almost 9 years
    Both are now empty, i think i must stick to the newly uploaded CI files. Its much more working :)