YII2 无法将 url 写入不同模块中的操作
YII2 Unable to write right url to an action in different modules
今天安装了Yii2。我已经努力重定向到模块操作 6 个多小时都没有成功。
project\app\modules\instClients\controllers\InstTypesController\actionCreate
索引文件在项目中
return $this->redirect(['instClients/instTypes/create'])
在 siteController/actionIndex 中创建 url
http://localhost/project/index.php?r=instClients/instTypes/create.
http://localhost/project/index.php?r=instClients/instTypes/create return未找到 (#404) 未找到页面。
我如何重定向到此操作,或者正确的 url 我应该使用什么来访问在模块 instClients 中的 instTypesController 中创建的操作?
提前致谢。
如果你想从一个页面重定向到另一个页面操作而不是 href
你不必在 link
中写 action
例如,如果您想重定向到 UserController
中名为 actionCreate
的操作,那么您的 href 将是这样的
/user/create
取决于您重定向的路径
我希望这能回答你的问题
我认为这也取决于您的 url 映射。您是否检查了 yii2 调试器以选择 url 映射并且它是正确的 url 映射。例如:
'<_m:[\w\-]+>/<_c:[\w\-]+>/<_a:[\w\-]+>/<id:\d+>' => '<_m>/<_c>/<_a>',
'<_m:[\w\-]+>/<_c:[\w\-]+>/<_a:[\w\-]+>/<item:\w+>' => '<_m>/<_c>/<_a>',
'<_m:[\w\-]+>/<_c:[\w\-]+>/<_a:[\w\-]+>/<sort:\w+>' => '<_m>/<_c>/<_a>',
'<_m:[\w\-]+>/<_c:[\w\-]+>/<_a:[\w\-]+>/<sort:\w+>/<id:\d+>' => '<_m>/<_c>/<_a>',
'<_m:[\w\-]+>/<_c:[\w\-]+>/<_a:[\w\-]+>' => '<_m>/<_c>/<_a>',
'<_m:[\w\-]+>/<_c:[\w\-]+>/<id:\d+>' => '<_m>/<_c>/view',
今天安装了Yii2。我已经努力重定向到模块操作 6 个多小时都没有成功。
project\app\modules\instClients\controllers\InstTypesController\actionCreate
索引文件在项目中
return $this->redirect(['instClients/instTypes/create']) 在 siteController/actionIndex 中创建 url http://localhost/project/index.php?r=instClients/instTypes/create.
http://localhost/project/index.php?r=instClients/instTypes/create return未找到 (#404) 未找到页面。
我如何重定向到此操作,或者正确的 url 我应该使用什么来访问在模块 instClients 中的 instTypesController 中创建的操作?
提前致谢。
如果你想从一个页面重定向到另一个页面操作而不是 href
你不必在 link
action
例如,如果您想重定向到 UserController
中名为 actionCreate
的操作,那么您的 href 将是这样的
/user/create
取决于您重定向的路径
我希望这能回答你的问题
我认为这也取决于您的 url 映射。您是否检查了 yii2 调试器以选择 url 映射并且它是正确的 url 映射。例如:
'<_m:[\w\-]+>/<_c:[\w\-]+>/<_a:[\w\-]+>/<id:\d+>' => '<_m>/<_c>/<_a>',
'<_m:[\w\-]+>/<_c:[\w\-]+>/<_a:[\w\-]+>/<item:\w+>' => '<_m>/<_c>/<_a>',
'<_m:[\w\-]+>/<_c:[\w\-]+>/<_a:[\w\-]+>/<sort:\w+>' => '<_m>/<_c>/<_a>',
'<_m:[\w\-]+>/<_c:[\w\-]+>/<_a:[\w\-]+>/<sort:\w+>/<id:\d+>' => '<_m>/<_c>/<_a>',
'<_m:[\w\-]+>/<_c:[\w\-]+>/<_a:[\w\-]+>' => '<_m>/<_c>/<_a>',
'<_m:[\w\-]+>/<_c:[\w\-]+>/<id:\d+>' => '<_m>/<_c>/view',