Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用initialize在cakephp3中进行https重定向无效_Cakephp_Cakephp 3.0 - Fatal编程技术网

使用initialize在cakephp3中进行https重定向无效

使用initialize在cakephp3中进行https重定向无效,cakephp,cakephp-3.0,Cakephp,Cakephp 3.0,我无法获取我所有控制器的以下代码(下面的搜索功能代码无法与Appcontroller中的代码一起使用)。问题是我有一些搜索函数,它们用参数再次调用函数。使用下面的代码初始化意味着我使用的搜索功能不再工作。有没有办法将httpds重定向的相同代码放在appcontroller而不是initialize函数中 //search controller which no longer works with htttps request from ap controller if (($thi

我无法获取我所有控制器的以下代码(下面的搜索功能代码无法与Appcontroller中的代码一起使用)。问题是我有一些搜索函数,它们用参数再次调用函数。使用下面的代码初始化意味着我使用的搜索功能不再工作。有没有办法将httpds重定向的相同代码放在appcontroller而不是initialize函数中

//search controller which no longer works with htttps request from ap controller

     if (($this->request->is('post') || $this->request->is('put'))) {
            //  debug( $this->request->data);
            if (isset($this->request->data['searchFilter'])) {
                $filter_url['controller'] = $this->request->params['controller'];
                $filter_url['action'] = $this->request->params['action'];
                $filter_url['page'] = 1;

                // for each filter we will add a GET parameter for the generated url
                foreach($this->request->data as $name => $value){
                    if($value){
                        $filter_url[$name] = urlencode($value);
                    }
                }
                //Post params are now GET paramaters
                return $this->redirect($filter_url); //this no longer works with the appcontroller redirect

            }//isset   filter

        }//post

............

 //app controller
 public function initialize()
    {
        parent::initialize();
        $this->loadComponent('Security', ['blackHoleCallback' => 'forceSSL']);
    }

    public function beforeFilter(Event $event)
    {

            $this->Security->requireSecure();

    }

    public function forceSSL()
    {
        return $this->redirect('https://' . env('SERVER_NAME') . $this->request->getRequestTarget());
    }