Ankita
Ankita

Reputation: 623

hide a id in url yii2 using urlManager

'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>'

I have written this rule in url manager so that it hide id during update action i want the url should be / the id should be hidden. But no luck. eg: I have this url mysite.com/controller/update/1 i want the url to be mysite.com/controller/update

Upvotes: 0

Views: 1541

Answers (1)

arogachev
arogachev

Reputation: 33548

What you are trying to achieve is impossible and useless.

Think about it logically. Action in this case simply won't know exactly what model should be loaded and updated.

I see only one possible use case of that.

When you load page post/update, then select post from list to update and load it with AJAX.

In this case just remove id from action parameters, you don't need to write additional url rules for that.

Upvotes: 4

Related Questions