• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Routing in Multilanguage website

I have found several examples of routing in web but in my case they did not work.
I used this code for routing:
PHP Code:
$route['^(\w{2})/(.*)$'] = '$2';
$route['^(\w{2})$'] = $route['default_controller']; 
but this code does not work when I use url aliases:
PHP Code:
$route['login'] = 'auth/login';
$route['logout'] = 'auth/logout'
for example, in this case 
this https://www.mydomain.com/tr/auth/login url works, 
but https://www.mydomain.com/tr/login this one does not work. 
Can anyboldy help me with it?

Thanks in advance

I solved it in following way:

Put this at the end of the routes.php
PHP Code:
$route['^(\w{2})/(.*)'] = function($language$link) use ($route)
   return isset($route[$link]) ? $route[$link] : $link;
$route['^(\w{2})$'] = $route['default_controller']; 

Please share if you have better solution

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.