Welcome Guest, Not a member yet? Register   Sign In
CI RegEx route issue
#1

[eluser]KeyStroke[/eluser]
I'm trying to make a site where the content's language is specified in the first URI segment. For example:

example.com/en/product/1 (English)
example.com/ar/product/1 (Arabic)

and so on.

How do I set routing so that it always treats the second segment (which is "product" in this case) as the controller, and not the first one?

I tried this:
Code:
$route['ar/(*)'] = "$1";
$route['en/(*)'] = "$1";

But it didn't work.

Will someone help me with this please?
#2

[eluser]champs[/eluser]
Your basic flaw is not having a period in your captured pattern, i.e. "(.*)". Without knowing your specific needs, this is a low-complication example of what you'd do if you want to be specific about which languages are allowed:

Code:
$route['(en|ar|de|nl|es|fr|ru|pt)*/*(.*)'] = '$2';
#3

[eluser]KeyStroke[/eluser]
That works wonderful. Thanks champs !! I apparently suck at RegEx. Smile




Theme © iAndrew 2016 - Forum software by © MyBB