tread
tread

Reputation: 11088

Yii URL manager routing additional variables not finding a route?

My current url manager:

'urlManager'=>array(
            'showScriptName'=>false,
            'urlFormat'=>'path',
            'rules'=>array(
                '<controller:\w+>/<id:\d+>'=>'<controller>/view',
                '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
                '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
                'rest/<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
                'rest/<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
            ),
        ),

With regards to the rest route

http://htt.local/rest/v1/show/2916

works!!

http://htt.local/rest/v1/candle/2916/from/2015-12-23
Unable to resolve request

Upvotes: 0

Views: 81

Answers (1)

hamed
hamed

Reputation: 8033

Your url manager should be like this:

'rules'=>array(
            '<controller:\w+>/<id:\d+>'=>'<controller>/view',
            '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
            '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
            'rest/<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

            /* Add this line */
            'rest/<controller:\w+>/<action:\w+>/<id:\d+>/from/<date>'=>'<controller>/<action>',
            /*  */

            'rest/<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
        ),

Upvotes: 1

Related Questions