2013-12-20 35 views
0

我正在使用Yii Framework。URL params中的“returnUrl”错误

在控制器中,保存模型后,我试图将用户重定向到/module/controller/action并将参数(redirectUrl)设置为另一个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似乎是正确的编码。任何想法都会有很大的帮助!

由于

+0

看来双斜杠是一个问题,也许尝试删除重定向URL的第一个正斜杠。 –

回答

2

你例如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);