Question

I'm building an website using Codeigniter and I've changed the way the URL looks from http://localhost/site_controller/home to http://localhost/home.

I've changed that by using .htaccess -> RewriteBase changing the $config['index_page'] to $config['index_page'] = '';
and in routes I've change like that:

$route['default_controller'] = "site";

$route['(:any)'] = "site/$1";

And it works fine only for the site controller, BUT my problem is that I have another controller named admin and when I try to login and make a redirect using redirect('admin/index') I get a 404 error.

How can I redirect from site controller to admin controller?

Was it helpful?

Solution

If you are going to route from (:any) => site you have to specify a higher priority route for the admin controller that overrides that route for those pages.

$route['default_controller'] = "site";

$route['admin/(:any)'] = "admin/$1";
$route['(:any)'] = "site/$1";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top