Welcome Guest, Not a member yet? Register   Sign In
Routing in Multilanguage website
#1

Hi,
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
Reply
#2

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
Reply




Theme © iAndrew 2016 - Forum software by © MyBB