Mahmoud K
Mahmoud K

Reputation: 85

Codeigniter problem with routes!

I am trying to do this route trick:

$route['cp/roles/:num'] = "cp/roles/index/:num";

but it doesn't work :( please help me!!

advanced thanks .

Upvotes: 1

Views: 174

Answers (2)

juanrossi
juanrossi

Reputation: 305

You could try

$route['cp/roles/:num'] = "cp/roles";

and then instead of passing a variable in your function you use

$this->uri->segment(3);

or the number that correspond to the segment.

Upvotes: 0

Sampson
Sampson

Reputation: 268442

According to the documentation on URI Routing:

$route['product/(:num)'] = "catalog/product_lookup_by_id/$1";

A URL with "product" as the first segment, and a number in the second will be remapped to the "catalog" class and the "product_lookup_by_id" method passing in the match as a variable to the function.

So, for your particular instance, you would do the following:

$route['cp/roles/(:num)'] = "cp/roles/index/$1";

Upvotes: 3

Related Questions