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