Yii Framework Forum: URL pattern for Rest interface not working - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

URL pattern for Rest interface not working Rate Topic: -----

#1 User is offline   olemara 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 53
  • Joined: 19-June 11

Posted 26 February 2012 - 07:01 AM

Hi,

I am trying to set up URL routing rules without success this far. Here are some of my rules:


        'urlManager'=>array(
            'urlFormat'=>'path',
            'showScriptName'=>false,
            'caseSensitive'=>false,
            'rules'=>array(
                '<controller:\w+>/<id:\d+>'=>'<controller>/view',
                '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
                '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
                /* business application API */
                array('businessapp/businessShops', 'pattern'=>'businessapp/businessShops/<username:\w+>', 'verb'=>'GET'),



My problem is this one:

                array('businessapp/businessShops', 'pattern'=>'businessapp/businessShops/<username:\w+>', 'verb'=>'GET'),


My request is being routed to the correct action, but I can not do $_GET['username']. However, if I declare a route like this:

                array('businessapp/businessShops', 'pattern'=>'businessapp/businessShops/<id:\d+>', 'verb'=>'GET'),


I can get the $_GET['id'] parameter. What am I missing here?

Any ideas would be appreciated,
OMA
0

#2 User is offline   twisted1919 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 645
  • Joined: 23-October 10
  • Location:Romania

Posted 26 February 2012 - 03:49 PM

Actually, this is how you should do it :
array('businessapp/businessShops/<username:\w+>', 'pattern'=>'businessapp/businessShops', 'verb'=>'GET'),

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users