Yii Framework Forum: urlManager rule not working - Yii Framework Forum

Jump to content

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

urlManager rule not working

#1 User is offline   K78 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 11-May 15

Posted 24 October 2017 - 09:02 AM

Hey guys,

I need to handle this kind of url structure {host}/{hash}/{controller}/{action}
The problem is that I can not get it to work while hash is in front of the controller.

Relevant part in configuration looks like this around the urlManager component:

'urlManager' => [
   'enablePrettyUrl' => true,
   'enableStrictParsing' => false,
   'showScriptName' => false,
   'normalizer' => [
      'class' => 'yii\web\UrlNormalizer',
      'action' => \yii\web\UrlNormalizer::ACTION_REDIRECT_TEMPORARY
   ],
   'rules' => [
      'GET <hash:[\w\-]+>/<controller:[\w\-]+>/<action:[\w\-]+>' => '<controller>/<action>'
   ]
]


Best regards!
0

#2 User is online   tri 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,824
  • Joined: 20-November 08
  • Location:Stockholm, Sweden

Posted 24 October 2017 - 10:27 AM

Perhaps this:
" Note that mode will be set to PARSING_ONLY when specifying verb in this way so you normally would not specify a verb for normal GET request."

http://www.yiiframew...l#$rules-detail

I don't know what the "\-" sequence will match. I think numeric chars "-" may be escaped/handled different than non-numeric chars.
Don't forget to read The Definitive Guide to Yii (1.1 en) (1.1 sv) (2.0 en) | The class reference (1.1) (2.0) has the details
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