1
votes

In my codeigniter project all my routes are working fine, apart from the default_controller, which always returns a 404. Sample of my routes:

$route['(:any)/(:any)/(:any)'] = 'home/$3'; // Region / language / page
$route['(:any)/(:any)'] = 'home/index'; // Region / language

$route['default_controller'] = "home/region_select";

So when the user first visits the site, the idea is to go to the default_controller, where he selects a region. All the other routes work. In the "Home" controller I have a "region_select" function. Any ideas much appreciated.

3
Do you have a file in application/controller/home/region_select.php? That's what is searches for now, and it looks like you want the default controller to load the function region_select, however this only fetches controller and loads index() inside it. - Robin Castlin

3 Answers

0
votes

Try this:

$route['default_controller'] = "home/region_select/";
$route['404_override'] = '';
0
votes

try this

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

and put the region_select function's content in to the index function of home controller and see what happens.

may be it will work.

please let me know if you face any problem.

0
votes

Ok, I have to apologise to everyone who answered for wasting their time. I discovered the issue was a conditional in my 'home' constructor, which took a URI segment and tested its validity, returning 404 if it was invalid. Of course, since the root has no URI segments, it returned invalid. I fixed it by checking for the presence of the URI segment before testing its validity. Thanks to everyone for their help.