这是我当前的网址https://localhost.com/vmmembers/view?name=aman
我想要这个https://localhost.com/window/aman
我使用以下代码尝试了此操作,但它不起作用:
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
[
'pattern' => 'signup',
'route' => 'site/signup'
],
[
'pattern' => 'about',
'route' => 'site/about'
],
'file/files/<file>' => 'file/files',
'<action:policy|terms>' => 'site/<action>',
'<controller:[A-Za-z-]+>/<id:\d+>/<title>' => '<controller>/view',
'<controller:[A-Za-z-]+>/<id:\d+>' => '<controller>/view',
'<controller:[A-Za-z-]+>/<action:[A-Za-z-]+>/<id:\d+>/<title>' => '<controller>/<action>',
'<controller:[A-Za-z-]+>/<action:[A-Za-z-]+>/<id:\d+>' => '<controller>/<action>',
'<controller:[A-Za-z-]+>/<action:[A-Za-z-]+>' => '<controller>/<action>',
'vmmembers/<name:\d+>' => 'window/view',
],
],
答案 0 :(得分:0)
您需要将此规则放在规则列表的开头:
'window/<name:\w+>' => 'vmmembers/view',