Error In Url Manager - Page Not Found

I want Url like this:


http://shopperspace.loc/posts/45

So I changed rules in UrlManager


'posts/<id:\w+>'=>'site/posts'

Then my action in siteController is




public function actionPosts($post_id){

              echo $post_id;}



It shows page not found!

I don’t know where it goes wrong!

in your url route you have named parameter “id” (‘posts/<id:\w+>’)

yet in action you request "post_id" parameter which does not match the request…

I changed this


public function actionPosts($post_id){

              echo $post_id;}

to


public function actionPosts($id){

              echo $id;}

Now it works