I would like to get URLs like http://mysite.com/user/1 to route to the function get($id) {...} of my Controller User.
I have tried the following in order to do so, but I get a 404 Error, Page Not Found rather than the output Hello, User 1.
Please can you tell me where I am going wrong?!
//routes file
$route['user/:id'] = "user/$1";
//user controller
function get($id) {
echo "Hi, User $id";
}
Edit—-
My code works perfectly when I run http://mysite.com/user/get/1, but not when I run http://mysite.com/user/1.
This should work:
More info at http://ellislab.com/codeigniter/user-guide/general/routing.html