urlManager rule not working


(Kuusekas) #1

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!


(tri - Tommy Riboe) #2

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.yiiframework.com/doc-2.0/yii-web-urlmanager.html#$rules-detail

I don’t know what the “\-” sequence will match. I think numeric chars “-” may be escaped/handled different than non-numeric chars.