CodeIgniter Forums

Full Version: What is wrong in this route rule?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]chefnelone[/eluser]
hello

I have this route where I need to have the :any segment in the $2 variable.

Code:
$route['[^/]+/:any/pos'] = 'index/$2';

Then if I have this url:

http://www.misite.com/es/products/pos

I'd expect that the route call to:

index/products

but it doesn't work...

But it works fine with:
Code:
$route['[^/]+/products/pos'] = 'index/products';

I can't see my mistake, /:any/ is segment 2, It isn't?

El Forum

[eluser]danmontgomery[/eluser]
You have to use groups to use backreferences:

Code:
$route['[^/]+/(:any)/pos'] = 'index/$1';

El Forum

[eluser]chefnelone[/eluser]
[quote author="noctrum" date="1279214130"]You have to use groups to use backreferences:

Code:
$route['[^/]+/(:any)/pos'] = 'index/$1';
[/quote]

thanks noctrum