Php 带有“的错误”;returnUrl";在URL参数中
我正在使用Yii框架 在控制器中,在模型保存后,我尝试将用户重定向到Php 带有“的错误”;returnUrl";在URL参数中,php,url,yii,Php,Url,Yii,我正在使用Yii框架 在控制器中,在模型保存后,我尝试将用户重定向到/module/controller/action,并将参数(重定向URL)设置为另一个URL。这是我的密码: $this->redirect(array('/module/controller/action/', 'redirectUrl'=>'/index.php/some/url/id/'.$id)); 这似乎很有效,因为我被重定向到: http://localhost/index.php/module/co
/module/controller/action
,并将参数(重定向URL)设置为另一个URL。这是我的密码:
$this->redirect(array('/module/controller/action/', 'redirectUrl'=>'/index.php/some/url/id/'.$id));
这似乎很有效,因为我被重定向到:
http://localhost/index.php/module/controller/action/redirectUrl/%2Findex.php%2Fsome%2Furl%2Fid%2F11
但当我到达那里时,我得到以下错误:
Not Found
The requested URL
/index.php/module/controller/action/redirectUrl//index.php/some/url/id/11 was not found on this server.
像/index.php/module/controller/action/redirectUrl/1234这样的URL工作正常
我不明白我在这里做错了什么,URL似乎编码正确。任何想法都会大有裨益
谢谢您的示例URL仅将1234
作为参数传递,而不是完整的相对URL,例如/index.php/some/URL/id/1234
。我想你想要的是:
$this->redirect(array('/module/controller/action/', 'redirectUrl'=>$id));
您可以跳过服务器上的URL规则,并通过以下方式最小化负载:
$this->redirect('/module/controller/action/redirectUrl/' . $id);
如果这不起作用,你怎么办
$this->redirect($this->createUrl('/module/controller/action/',
array('redirectUrl'=>$id));
然后只需在操作中添加“/index.php/some/url/id/”
似乎双正斜杠是个问题,也许可以尝试删除重定向url的第一个正斜杠。
$this->redirect($this->createUrl('/module/controller/action/',
array('redirectUrl'=>$id));