1

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

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

am actually looking to hard code the parameter. people will hit "domain.com/product_unique_and_rare" only and I want some parameters lets say x and y sent to the method.
Thanks I think hard coding also works params are passed to the method including the r-segments array

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.