I have controller Post
with methods index
, add
and delete
. I create routes rule for this actions:
$route['posts'] = 'post/index'; // <-- Work
$route['post-add'] = 'post/add';// <-- Work
$route['post-delete/(:num)'] = 'post/delete/$1'; // <-- Not Work
First route www.example.com/posts
work good, and second with /post-add
work. But when i call post-delete/5
that not work, all time i get 404 Not Fount
.
Here is controller
class Post extends MY_Controller
{
public function index()
{
//.
}
public function add()
{
//.
}
public function delete($id)
{
echo "Delete post #ID =" $id;
}
}
I have only problem with delete
route i dont know whay he dont accept that parameter.
Work:
Not work:
What can be problem?
Add it to route file
$route['delete/(:num)'] = 'post/delete/$1'