Regex Yii URL模式中的Yii合并和可选字符串
有没有办法整合以下Yii URL模式?例如,如何说零件是可选的Regex Yii URL模式中的Yii合并和可选字符串,regex,yii,yii-url-manager,Regex,Yii,Yii Url Manager,有没有办法整合以下Yii URL模式?例如,如何说零件是可选的 '<category:.+>-rezepte/mit-<ingredient:\w+>/<effort:\d+>/<difficulty:\w+>' => 'recipes/index', '<category:.+>-rezepte/mit-<ingredient:\w+>/<effort:\d+>'
'<category:.+>-rezepte/mit-<ingredient:\w+>/<effort:\d+>/<difficulty:\w+>' => 'recipes/index',
'<category:.+>-rezepte/mit-<ingredient:\w+>/<effort:\d+>' => 'recipes/index',
'<category:.+>-rezepte/mit-<ingredient:\w+>' => 'recipes/index',
'<category:.+>-rezepte' => 'recipes/index',
'rezepte-mit-<ingredient:.+>/<category:\w+>/<effort:\d+>/<difficulty:\w+>' => 'recipes/index',
'rezepte-mit-<ingredient:.+>/<category:\w+>/<effort:\d+>' => 'recipes/index',
'rezepte-mit-<ingredient:.+>/<category:\w+>' => 'recipes/index',
'rezepte-mit-<ingredient:.+>' => 'recipes/index',
'-rezepte/mit-/'=>“配方/索引”,
“-rezepte/mit-/”=>“配方/索引”,
“-rezepte/mit-'=>'配方/索引',
'-rezepte'=>“配方/索引”,
“rezepte mit-//”=>“配方/索引”,
“rezepte mit-/”=>“配方/索引”,
“rezepte mit-/”=>“配方/索引”,
“rezepte mit-”=>“配方/索引”,
根据需要,您应该能够执行以下操作:
array(
'recipes/index',
'pattern' => '<category:\w+>-rezepte(/mit-<ingredient:\w+>)?(/<effort:\d+>)?(/<difficulty:\w+>)?',
),
数组(
“配方/索引”,
'模式'=>'-rezepte(/mit-)?(/)?(/)?',
),
尝试将可选部分放在括号和问号之间,例如:()?如果我设置了()?我从Yii的createUrl()中获取了错误的url。比如:category1-rezepte/mit-ingre1/60(/all)?