Codeigniter Default Controller in a Sub Directory Not Working

CodeIgniter default controller in a sub directory not working

For each sub-folder in your controllers folder you must specify a default controller in routes.php. The built in $route['default_controller'] will not work for sub-folders.

e.g: For setting the default controller for you folder sub-folder to home add the following to your /application/config/routes.php file:

$route['folder'] = "folder/home";

which means http://mysite.com/folder/ is the same as http://mysite.com/folder/home as URL.

Codeigniter 2.0 default controller for sub folder not working in server but working in localhost

I followed the answer from the following url and it worked for me.

http://codeigniter.com/forums/viewthread/181149/#857629

yet would like to know why it was working normally like in the localhost.

Codeigniter 4 subdirectory controller not accessible on remote server

The screenshot of your filesystem shows your admin/ directory is all lower case. It should start with a capital A. From the docs:

Organizing Your Controllers into Sub-directories

If you are building a large application you might want to hierarchically organize or structure your controllers into sub-directories. CodeIgniter permits you to do this.

Simply create sub-directories under the main app/Controllers/ one and place your controller classes within them.

Important

Folder names MUST start with an uppercase letter and ONLY the first character can be uppercase.

If you would rather use lower case a, or if you simply want more transparent control of your routing, set up routes.

CodeIgniter Routing Not Working in Sub Directory

You don't need to include subdir in your route.

Hence update your $route['users/login'] to route to following:

$route['users/login'] = 'users/login';

Edit 1:

in your root create a .htaccess file if it doesnot exist and save the following content in it to remove index.php from your URL:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?/$0 [PT,L]


Related Topics



Leave a reply



Submit