I have the following code:
public function beforeControllerAction($controller, $action)
{
if(parent::beforeControllerAction($controller, $action))
{
if (Yii::app()->params['prod'] == 1 && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on")) {
$url = "https://". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
header("HTTP/1.1 301 Moved Permanently");
header("Location: $url");
exit;
}
return true;
}
else
return false;
}
in the UserModule.php file that redirects from http to https
the problem is, if there is an exception error (if I throw a CHTTpException) in the Module, I get a redirect loop. What can I do to prevent that?