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
.
Author by
user3651476
Updated on June 05, 2022Comments
-
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 almost 9 yearsYes, inside my controller i have login.php
-
Abdulla Nilam almost 9 yearscheck file inside and base url too
-
Abdulla Nilam almost 9 years
login
should beLogin
-
user3651476 almost 9 yearsclass login extends CI_Controller {} my class name here is small. so my file name should be small caps too, right?
-
Abdulla Nilam almost 9 yearsnoo. its ok change this
class Login extends CI_Controller
-
user3651476 almost 9 yearswhen i tried to upload a new CI 3.0 files, i got this. Please se link. bellanueskincare.com/POS
-
Abdulla Nilam almost 9 yearschange
login
toLogin
inside controller -
user3651476 almost 9 yearsbellanueskincare.com/System/login still an error page, changing base_url = '' and login class name to Login
-
Abdulla Nilam almost 9 yearsremove baseurl function in config.php
-
user3651476 almost 9 yearsyou want me to remove/comment this line ? $config['base_url'] = '';
-
Abdulla Nilam almost 9 yearsNo men.
$config['base_url'] = '';
should be empty. and$config['index_page'] = '';
also empty -
user3651476 almost 9 yearsBoth are now empty, i think i must stick to the newly uploaded CI files. Its much more working :)