Created
March 12, 2014 11:14
-
-
Save Chintanvpatel/9504893 to your computer and use it in GitHub Desktop.
SSL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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