tags:

views:

41

answers:

1

Say I wanted the following URL scheme, which I got to work by setting the following URI route.

http://www.domain.com/profile/jimbob123

$route['profile'] = "profile/index";
$route['profile/(:any)'] = "profile/index/$1";

Now, let's say I want my URL to look like the following when I want to display a "status."

http://www.domain.com/profile/jimbob123/status/908734efc

How do I go about passing "jimbob123" and "908734efc" into my method so I can check and retrieve this particular record? I tried the following but it doesn't seem to work.

$route['user/(:any)/status/(:any)'] = "user/plan/$1/$2";
+1  A: 

I assume where you wrote user/(:any)/status/(:any) you meant profile/(:any)/status/(:any)

That might be one problem, also this:

The routes are matched in the order they are declared. If you wrote it like this:

$route['profile'] = "profile/index";
$route['profile/(:any)'] = "profile/index/$1";
$route['profile/(:any)/status/(:any)'] = "user/plan/$1/$2";

It wont work because "http://www.domain.com/profile/jimbob123/status/908734efc" matches the second route.

If you swap the second and third line you should be good.

$route['profile'] = "profile/index";
$route['profile/(:any)/status/(:any)'] = "user/plan/$1/$2";
$route['profile/(:any)'] = "profile/index/$1";
Ken Struys
Ah ok ... can you take a look at the following link? http://brandonbeasley.com/blog/codeigniter-vanity-urls/ Line #7 in his route.php file, what is that meant for?
luckytaxi
I assume that line 7 takes you to a user profile page where you can either add or edit user information. I would usually do this through two functions since it's related to two operations, so I don't know why he's mapping it to a single function. note that line 8 routes wont match like 7 routes, unlike your case where :any will pick up any set of characters.
Ken Struys