Welcome Guest, Not a member yet? Register   Sign In
help with routes[]
#1

[eluser]chefnelone[/eluser]
Hello
I'm trying to make a route rule. Something like:

Code:
$route[':any/services'] = 'index/services';

which works fine with:

Code:
http://192.1/ci/something-1/services


but the problem is that the rule applies also when there are 2 segments before /services. Then it applies whith:

Code:
http://192.1/ci/something-1/something-2/services

I need the rule to apply only when there is ONLY 1 segment before /services but not when there are 2 segments before /services.
The segment before /services must be :any though

thanks
#2

[eluser]mddd[/eluser]
You can use [^/]+ instead of :any. That will match only one segment.
So that would make:
Code:
$route['[^/]+/services'] = 'index/services';
#3

[eluser]chefnelone[/eluser]
[quote author="mddd" date="1276280381"]You can use [^/]+ instead of :any. That will match only one segment.
So that would make:
Code:
$route['[^/]+/services'] = 'index/services';
[/quote]

thanks mddd




Theme © iAndrew 2016 - Forum software by © MyBB