Skip to content

Instantly share code, notes, and snippets.

@visualizeq
Created October 16, 2012 08:27
Show Gist options
  • Save visualizeq/3898041 to your computer and use it in GitHub Desktop.
Save visualizeq/3898041 to your computer and use it in GitHub Desktop.
Yii HttpsFilter Class
<?php
class HttpsFilter extends CFilter {
protected function preFilter($filterChain) {
if (!Yii::app()->getRequest()->isSecureConnection) {
# Redirect to the secure version of the page.
$url = 'https://' .
Yii::app()->getRequest()->serverName .
Yii::app()->getRequest()->requestUri;
Yii::app()->request->redirect($url);
return false;
}
return true;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment