Welcome Guest, Not a member yet? Register   Sign In
URI routing with regular expressions - can't get it done
#11

[eluser]toopay[/eluser]
NOT NECCESARY to leave your config blank, you do it if you want allow some regex (or any disallow character) on your url.

Its sounds quite unbelievable, so you try to explain that what happens is :
Code:
//this works
$route['ro/despre-noi'] = "despre";
$route['ro/about-us'] = "despre";
//this not works
$route['ro/despre-noi|ro/about-us'] = "despre";
//this not works too
$route['(ro\/despre-noi|ro\/about-us'] = "despre";  = "despre";

May i ask you one question, what happens if user just write down the url in their browser address like "http://www.mysite.com/despre" instead of "http://www.mysite.com/[lang, ro|en]/despre", are they :
1. Meet the 404 error or
2. Meet your controller and their url automatically rewrite to "http://www.mysite.com/[lang, ro|en]/despre"
#12

[eluser]toopay[/eluser]
sorry, the last line should
Code:
// too fast when copy this line : $route['(ro\/despre-noi|ro\/about-us'] = "despre";  = "despre";
$route['(ro\/despre-noi|ro\/about-us'] = "despre";
#13

[eluser]George I[/eluser]
Twisted1919,
Code:
$route['ro/(despre-noi|about-us)'] = "despre";
$route['en/(despre-noi|about-us)'] = "despre";
doesn't work, nor does
Code:
$route['(ro/(despre-noi|about-us))|(en/(despre-noi|about-us))'] = "despre";
Looks like either I'm doing something wrong or CI doesn't accept regexp as routing rules after all.
#14

[eluser]George I[/eluser]
I think I figured it out.

I had 2 lines in my routes.php file, according to the i18n library recommendations:
Code:
$route['^ro/(.+)$'] = "$1";
$route['^en/(.+)$'] = "$1";
Those lines were placed right after
Code:
$route['default_controller'] = "home";
As soon as I commented these lines,
Code:
$route['(ro|en)/(despre-noi|about-us)'] = "despre";
started working.




Theme © iAndrew 2016 - Forum software by © MyBB