Reputation: 31
I'm in trouble with a codeigniter route,
I need to do this:
method/:any = method/index_function
method/edit/:any = method/edit_function
I wrote this in the route config file:
$route['method/:any'] = 'method/index';
$route['method/edit/:any'] = 'method/edit';
But don't want works.
Any suggestions?
resolve!
I change the order of the line in the route file:
$route['method/edit/:any'] = 'method/edit';
$route['method/:any'] = 'method/index';
thanks to Basheer Ahmed
Upvotes: 2
Views: 710
Reputation: 4292
Routes will run in the order they are defined. Higher routes will always take precedence over lower ones. Codeigniter Routes
$route['method/edit/(:any)'] = 'controller/edit';
$route['method/(:any)'] = 'controller/index';
Upvotes: 3
Reputation: 158
You forgot to apply parenthesis basically. Codeigniter routing really works great. Here is an example how I achieved the same in my project :
$route['listnote/stepone/(:any)']='listnote/listnote/loanInformation';
Upvotes: 0
Reputation: 698
If I am not mistaken, your route key can not have the same name as an existing controller, because CodeIgniter will check for a Controller first, and if it finds one, it will try to call the method in that controller. Please try:
$route['m/:any'] = 'method/index';
$route['m/edit/:any'] = 'method/edit';
Upvotes: 1