Question

I am using Yii 1.1.14.

I want to convert
http://website.com/controller/action?param1=value1&param2=value2
to
http://website.com/value1/value2

How to do this in urlManager?

Était-ce utile?

La solution

First, check this to hide index.php:

http://www.yiiframework.com/doc/guide/1.1/en/topics.url#hiding-x-23x

Then, the route in config.php should be like this:

'<param1:\w+>/<param2:\w+>'=>'mycontroller/myaction',

The method myaction should accept $param1 and $param2 in its constructor to be passed automatically by Yii.

This would make your app unable to look for other controllers, because that rule will accept every route with 2 words separated by /

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top