Question

I am using codeigniter re-route to clean up some urls. I am aware that I can do

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

But in some cases I have to add some extra parameters to the redirect url so that I get them as a param to the method. for example

$route['product_unique_and_rare'] = "catalog/product_lookup_by_id/{HERE I WANT SOME ADDITIONAL EXTRA PARAM}";

How to do this so that I get the value in the param of the method rather than the value in uri->resegment

Was it helpful?

Solution

you can try this

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

Get the param in product_lookup_id like this

function product_lookup_id($product_id){
    /*$product_id will be the passed parameter*/
}

So, if someone goes for http://domain.com/product_unique_and_rare/23, $product_id will get the value 23.

You can hard-code the parameter too, but I believe you aren't looking for that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top