使用url中的参数来阻止PHP重定向 [英] Cake PHP redirect with parameters in url

查看:173
本文介绍了使用url中的参数来阻止PHP重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面,我想重定向到,需要在URL中的参数:
http://www.example.com/myController/myAction/param1:val1/param2:val2

I have a page that I want to redirect to that requires parameters in the URL: http://www.example.com/myController/myAction/param1:val1/param2:val2

我知道有一个用于重定向的CakePHP重定向函数,其工作方式如下:

I know that there is a CakePHP redirect function for redirecting that works as follows:

 $this->redirect(array("controller" => "myController",
                       "action" => "myAction",
                       $data_can_be_passed_here),
                 $status, $exit);

如何使用上述函数添加我想要的参数作为url的一部分?

How do I add the parameters that I want as part of the url using the above function?

我认为可能有另一个元素,我可以添加到数组,以便我可以传递 param1:val1 param2:val2

I would think that there might be another element that I could add to array so that I can pass along param1:val1 and param2:val2.

任何帮助将非常感谢!

推荐答案

知道为什么我不能在CakePHP文档中找到这个,但我终于找出了解决方案。我在这里张贴,以防任何其他人有同样的问题。 (

I do not know why I was not able to find this in the CakePHP documentation, but I did finally figure out the solution. I am posting it here in case anyone else has the same problem. (If someone knows where this is in the documentation please post it as well, thanks!)

要重定向到以下网址:

http://www.mysite.com/myController/myAction/param1:val1 / param2:val2

您可以使用:


$this->redirect(array("controller" => "myController", 
                      "action" => "myAction",
                      "param1" => "val1",
                      "param2" => "val2",
                      $data_can_be_passed_here),
                $status,
                $exit);


希望它有帮助!

这篇关于使用url中的参数来阻止PHP重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆