我已为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());
}
}
感谢任何帮助。