Welcome Guest, Not a member yet? Register   Sign In
Codeigniter - How do I rewrite url’s with url parameters
#1

[eluser]Irshad Sheikh[/eluser]
Hi,

I need to turn URL's like /item/2 into cleaner URL's like /item/product-name-here. I'm using codeigniter. I setup rewriting in the routes.php file like this:

$route['item/(:any)'] = 'item/$1';

My question is: where do I replace the product ID "/2" with "/product-name-here"? I can successfully get the param $1 and fetch the product name, but I can't figure out how to rewrite the URL with this dynamic value.

Thank you very much!
#2

[eluser]Phil Sturgeon[/eluser]
That is not possible. You should store product-name-here in the database then use that to fetch the data instead of requiring an ID.




Theme © iAndrew 2016 - Forum software by © MyBB