Welcome Guest, Not a member yet? Register   Sign In
404 on routes in sub folder
#1

I inherited a codeigniter website, and upgraded codeigniter. Figured out the controller files have to start with capital letters, and I got most of the routes and views working again. Except for the Admin portion of the site. The routes for this portion is not in the routes.php file, but in a different file. And the controllers is in a sub directory called admin, which I renamed to Admin. So even though there is for example an entry:

PHP Code:
$route['admin'] = 'admin/admin/index' 

When I go to /admin I get 404, and logs show:
Code:
404 Page Not Found: Admin/admin

I've even tried putting eg
PHP Code:
$route['admin/login'] = "admin/admin/login"
in the routes.php file, but I still see in the logs
Code:
404 Page Not Found: Admin/admin
even though:

Code:
$ grep admin config/routes.php
route['admin/login'] = "admin/admin/login";
$ grep login controllers/Admin/Admin.php
    public function login()
How can I troubleshoot these 404 errors in order to properly load the routes in the sub folder?
Reply
#2

(This post was last modified: 10-21-2020, 10:58 AM by InsiteFX.)

PHP Code:
/**
 * Begin Authentication Library Routes.
 */
$route['login']           "admin/admin/login";
$route['logout']          "admin/admin/logout";
$route['register']        "admin/admin/register";
$route['admin/dashboard'] = "admin/admin/index";
// End of Authentication Library Routes. 

The left side should be methods in your admin/Admin.php
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

Thanks for the advise InsiteFX

I added this to my routes.php:

PHP Code:
$route['admin/dashboard'] = "admin/admin/index"

However, when I visit /admin/dashboard, i am still getting 404 not found.

Any other suggestions?
Reply
#4

Change it to below because it looks like you do not have a dashboard method in your Controller.

PHP Code:
$route['admin/dashboard'] = "admin/admin/index";

// change to
$route['admin'] = "admin/admin/index"
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB