So I am using a Codeigniter 2.1 Internationalization i18n Library and I need to adapt my routes to use the language parameters in my short urls where I remove the controller’s name:
$route['default_controller'] = "home";
#$route['^(en|es|ro)/(.+)$'] = "$2";
#$route['^(en|es|ro)$'] = $route['default_controller'];
$route['results$'] = "fetch/results";
$route['video/(:any)'] = "fetch/video/$1";
$route['tag/(:any)'] = "fetch/tag/$1";
$route['404_override'] = '';
So I need to make this work http://localhost/app/en/results?query=t-shirts instead of http://localhost/app/en/fetch/results?query=t-shirts
How can I accomplish that?
Edit:
$route['^(en|es|ro)/results$'] = "fetch/results";
$route['^(en|es|ro)/video/(:any)'] = "fetch/video/$1";
$route['^(en|es|ro)/video/(.+)$'] = $route['^(en|es|ro)/(.+)$'] = "$2";"fetch/video/$2";
None of the above works.
If I do http://localhost/app/en/fetch/video/asfasf works perfectly
This doesn’t http://localhost/app/en/video/asfasf
The error I get is a 404:
404 Page Not Found
The page you requested was not found.
Found the problem
So, for some reason having this set : $route['^(en|es|ro)/(.+)$'] = "$2"; before what I was trying to do was causing the problem.
For anybody that uses that library and wants to set custom routes, in order for them to work you’ll have to do it in this order:
example: