Skip to content

Instantly share code, notes, and snippets.

@Chintanvpatel
Created March 12, 2014 11:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Chintanvpatel/9504893 to your computer and use it in GitHub Desktop.
Save Chintanvpatel/9504893 to your computer and use it in GitHub Desktop.
SSL
<?php
class NIC_Controller_Plugin_Ssl extends Zend_Controller_Plugin_Abstract
{
public function preDispatch ( Zend_Controller_Request_Abstract $request )
{
$this->_secureUrl($request);
}
protected function _secureUrl ( Zend_Controller_Request_Abstract $request )
{
$server = $request->getServer();
$hostname = $server['HTTP_HOST'];
if ( ! $request->isSecure() )
{
$url = Zend_Controller_Request_Http::SCHEME_HTTPS . "://" . $hostname . $request->getRequestUri();
$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
$redirector->setGoToUrl($url);
$redirector->redirectAndExit();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment