php - Configuring urlManager Rules in Yii2 -
i'm new using yii2 , have been using urlmanager, have following code, works fine think should shorter. have couple rules follows :-
'rules' => [ 'gifts/<subjectone:[\s\s]+>/<subjecttwo:[\s\s]+>' => 'gifts/index', 'gifts/<subjectone:[\s\s]+>/<subjecttwo:[\s\s]+>/' => 'gifts/index', 'gifts/<subjectone:[\s\s]+>' => 'gifts/index', 'gifts/<subjectone:[\s\s]+>/' => 'gifts/index', ];
as can see i've added 4 rules go same page handle different situations.
i've had add same url's twice, once /
, 1 without stop 404's. please advise of better way handle this.
you can add +|(\/?)
@ trailing of rule. take look:
'gifts/<subjectone:[\s\s]+>+|(\/?)' => 'gifts/index',
so there no need write rules twice.
Comments
Post a Comment