Reputation: 168
I've recently picked up Codeigniter as a fun little side project, now I'm trying to make my routes to be as follows;
http://localhost/c/show/ID
should translate into
http://localhost/c/ID
I do it in routes in config like so;
$route['c/:any'] = "c/show/$1";
However, the ID is simply passed as plaintext, which means the ID passed to my show() function is $1, and not whatever ID is set to.
Am I going about this wrong? I've simply looked around in their documentation and even tried copy&replace to make sure it's not something that I typed wrong.
Now I fear I might have missunderstood something but I cannot phatom what that could be.
Really grateful for any and all help!
Upvotes: 1
Views: 930
Reputation: 166
":any" should be in brackets, like this:
$route['c/(:any)'] = "c/show/$1";
Btw if ID is numeric, it's better to use:
$route['c/(:num)'] = "c/show/$1";
Upvotes: 5