Gihan Dilusha
Gihan Dilusha

Reputation: 921

how to rewrite url formatting with parameter name in yii

i'm very new to Yii, Normally yii serve like this url format

baseurl/app_dir/conroller/action/parametername/vaule

But i want to show up it like this

baseurl/app_dir/conroller/action/vaule

means without parameter name.

i read lot of solutions but couldn't find, does anybody knows how to do it, please help me.

Upvotes: 1

Views: 695

Answers (1)

user133408
user133408

Reputation:

It is somewhere in docs, here is example:

'/user/<id:\w+>/' => 'user/view/'

This means, that request /user/someUserName will be directed to action view in controller user with parameter id with value someUserName. This way you have urls with just value, but in application it is available as named $_GET parameter.

NOTE: \w+ is just regex, which are supported here, you could for example use \d+ to limit value to numeric etc.

Upvotes: 2

Related Questions