在cakephp 3中执行ssl后,返回$ this-> redirect()停止工作

时间:2017-10-21 11:36:07

标签: cakephp-3.0

我已为ssl实施实施了以下代码,但之后我的重定向不再有效:

这是我的代码:

namespace App\Controller;

use App\Controller\AppController;
use Cake\Event\Event;

class WidgetsController extends AppController
{

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

public function beforeFilter(Event $event)
{

        $this->Security->requireSecure();

}


public function testRedirect()
{

        **$this->redirect("/controller/Somewhere");**

}

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

感谢任何帮助。

0 个答案:

没有答案