mysite/users triggers usersController index action.
Now I want to send mysite/users/123 to usersController.
How Can I do it ? and where to will go this request if not to index action ?
mysite/users triggers usersController index action.
Now I want to send mysite/users/123 to usersController.
How Can I do it ? and where to will go this request if not to index action ?
Updated form comments discussion
If you want to pass 123 to the controller you need to set the named parameter in the urlManager of the config/main.php file.
'something/<namedParameter:Pattern>' => 'MyControllerToCall/MyMethodofControllerToUse'
So for you:
'users/<username:\d+>' => 'users/view'
In the view
public function actionView($username){
echo $username;
}
That will only work in the view method though as the 123 part is being taken from the URL and you have configured Yii so when the url mysite/users/ is displayed like mysite/users/123. It calls the View method of the users Controller.
'users' => 'users/view'. Then in that will call the users Controller and the view method. But no, it won't do that because you haven't passed anything to the left hand side of the rule. The other I answer I gave you will do what you ask. But that was for the url users/123. This rule you said mysite/users. But, normally I would say if you are having a url like mysite/user, then it would call the index (users/index) method and get all users. Then the url users/123 is more specific and would call just the user with the username 123