Welcome Guest, Not a member yet? Register   Sign In
Trick to delete controller in query string
#2

[eluser]Jelmer[/eluser]
That's by far not the best way to do this, in fact it's a pretty bad one since you'd have to edit your /system/ files on every CI update. Also it's bad because there's a pretty simple way to do the same within the system\application\config\routes.php file.

If I understand you correctly, you want every request to be handled by the same default controller if no controller can be found. While there are I believe even better ways to do this, the way I solved this problem was by first registering all my other controllers and then closing with the default router which is set to 'welcome' by the final rule:
Code:
$route[':any'] = 'welcome';

All the others you'll have to set before that rule by adding them:
Code:
$route['other_controller/(:any)'] = 'other_controller/$1';

Or with 2 rules if you want it to work without the function set as well:
Code:
$route['other_controller/(:any)'] = 'other_controller/$1';
$route['other_controller'] = 'other_controller';

I'll admit it's a bit more work, but keeping the system files without edits will save you many headaches when updating CI to the latest version.


Messages In This Thread
Trick to delete controller in query string - by El Forum - 12-01-2008, 07:30 PM
Trick to delete controller in query string - by El Forum - 12-01-2008, 08:25 PM
Trick to delete controller in query string - by El Forum - 12-01-2008, 10:48 PM
Trick to delete controller in query string - by El Forum - 12-02-2008, 10:28 PM



Theme © iAndrew 2016 - Forum software by © MyBB