CodeIgniter Forums
Help with routes.php, please - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Help with routes.php, please (/showthread.php?tid=56239)



Help with routes.php, please - El Forum - 12-04-2012

[eluser]indapublic[/eluser]
Hello, all.

I develop multi-language system. I use this solution but I need correction with routes.

My routes.php containg now:

Code:
$route['^(ru|en)/(.+)$'] = "$2";
$route['^(ru|en)$'] = $route['default_controller'];

and mysite.ru/ru/test and mysite.ru/en/test working correctly.

But I want too this behavior:

http://mysite.ru/test -> http://mysite.ru/{default language or language i will set}/test

How I do it?

Thank you


Help with routes.php, please - El Forum - 12-04-2012

[eluser]Aken[/eluser]
Use your .htaccess to redirect URLs that don't have the beginning language segment. That's what I'd do, at least. Maybe someone else can suggest something different.


Help with routes.php, please - El Forum - 12-04-2012

[eluser]indapublic[/eluser]
[quote author="Aken" date="1354683036"]Use your .htaccess to redirect URLs that don't have the beginning language segment. That's what I'd do, at least. Maybe someone else can suggest something different.[/quote]
Yep, it is possible. But I want to try use routes for this.

Update: I want to change default language dynamically, .htaccess don't help me with it.


Help with routes.php, please - El Forum - 12-04-2012

[eluser]Aken[/eluser]
Dynamically based on what?


Help with routes.php, please - El Forum - 12-05-2012

[eluser]indapublic[/eluser]
[quote author="Aken" date="1354686239"]Dynamically based on what?[/quote]
If user is logged, it will be language from user settings. If anonymous, it will be russian, for example


Help with routes.php, please - El Forum - 12-05-2012

[eluser]Aken[/eluser]
Best to use a MY_Controller or hook to do the logic and redirect before any other code has loaded.