Reputation: 87
I implemented i18n to my ci app according to http://codeigniter.com/forums/viewthread/179036/ but my custom routes are not working anymore.
/* custom routes */
// URI like '/en/about' -> use controller 'about'
$route['^(en|de)/(.+)$'] = "$2";
// '/en' and '/de' URIs -> use default controller
$route['^(en|de)$'] = $route['default_controller'];
$route['register'] = 'auth/register';
$route['login'] = 'auth/login';
$route['logout'] = 'auth/logout';
'register', 'login' and 'logout' are not routed to auth/something. Any idea why? I am getting 404 error (when I open en/login it wants to use login controller instead of auth)
Upvotes: 2
Views: 1254
Reputation: 3343
Route are executed in the order they appear in your routes.php
. So when your try en/login
it will reach the line which says $route['^(en|de)/(.+)$'] = "$2";
and then route it to the controller login
You actually want to do 2 different re-routes.. (from en/login
-> 'login' -> 'auth/login' ) thats why its failing.
You probably just need to add a special rules for auth stuff like this:
$route['^(en|de)/register'] = 'auth/register';
$route['^(en|de)/login'] = 'auth/login';
$route['^(en|de)/logout'] = 'auth/logout';
.. and make sure to put it before your generic i18n routes.
read the online documentation for more information.
Upvotes: 3