Setting codeigniter routes for language path Setting codeigniter routes for language path codeigniter codeigniter

Setting codeigniter routes for language path


This kind of defeats the purpose of controllers, but if you know that anything with "results" as the second segment should use the "fetch" controller, you could do this:

$route['^(en|es|ro)/results$'] = "fetch/results";

EDIT:

It's because your (:any) line is catching before the right one. Also, a "." (dot) character will match a forward slash too, which probably isn't what you want.

$route['^(en|es|ro)/results$']       = "fetch/results";$route['^(en|es|ro)/video/([^/]+)$'] = "fetch/video/$2";$route['^(en|es|ro)/video/(:any)']   = "fetch/video/$1";


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:

  1. custom routes
  2. The routes added by the library

example:

$route['default_controller'] = "home";//First$route['^(en|es|ro)/video/(.+)$'] = "fetch/video/$2";$route['^(en|es|ro)/results$']     = "fetch/results$2";//Second$route['^(en|es|ro)/(.+)$']        = "$2";$route['^(en|es|ro)$'] = $route['default_controller'];$route['404_override']  = '';