Cake PHP redirect with parameters in url

前端 未结 4 1481
挽巷
挽巷 2020-12-24 11:57

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

I know that there

4条回答
  •  旧时难觅i
    2020-12-24 12:54

    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!)

    To redirect to the URL:

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

    You can use:

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

    Hope it helps!

提交回复
热议问题