I have such a url - http://site.ru/1 There is such a rule

'<id:\d+>' => 'main/public-page' 

and such

 '<sid:\d+>/<uid:\d+>' => 'account/account' 

Do they define rules for urla, which is higher or not? And if not, when will they work? At what url?

  • the second rule definitely requires two url segments, so they will not intersect - etki
  • and the first rule? - Diefair
  • and the first rule will work only on one numerical segment - etki
  • that is, it will work for this - http://site.ru/1 ? - Diefair

1 answer 1

The sequence of rule processing is a sequence in the array of rules. Yes, you will work the first rule for http://site.ru/1

 '<id:\d+>' => 'main/public-page' 

/ 1 => MainController / actionPublicPage ($ id = 1)

 '<sid:\d+>/<uid:\d+>' => 'account/account' 

/ 1/2 => AccountController / actionAccount ($ sid = 1, $ uid = 2)

As an example, for clarity, a couple more rules

 '<action:[0-9a-zA-Z_\-]+>' => 'web/default/<action>', 

/ login => WebModule / DefaultController / actionLogin

/ profile => WebModule / DefaultController / actionProfile

 '<action:[0-9a-zA-Z_\-]+>/<token:\d+\-[A-Fa-f0-9]+>' => 'web/default/<action>' 

/ activate? token = FA123 => WebModule / DefaultController / actionActivate ($ token = 'FA123')