Skip to content

Instantly share code, notes, and snippets.

@notomato
Created March 31, 2014 06:03
Show Gist options
  • Save notomato/9886177 to your computer and use it in GitHub Desktop.
Save notomato/9886177 to your computer and use it in GitHub Desktop.
SSL redirection in lithium controller
<?php
/**
* Redirect to SSL if we are not in development mode.
*
* @param object $request
* @param array $params
* @param array $options
*
* @return object
*/
public function __invoke($request, $params, array $options = array()) {
if ($request->is('ssl') || Environment::is('development')) {
return parent::__invoke($request, $params, $options);
}
return $this->redirect(Router::match($request->url, $request, [
'absolute' => true, 'scheme' => 'https://'
]));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment