Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. $hook['post_controller_constructor'][] = array(
  2. 'function' => 'redirect_ssl',
  3. 'filename' => 'ssl.php',
  4. 'filepath' => 'hooks'
  5. );`
  6.  
  7. function redirect_ssl() {
  8. $CI =& get_instance();
  9. $class = $CI->router->fetch_class();
  10. $exclude = array('client'); // add more controller name to exclude ssl.
  11. if(!in_array($class,$exclude)) {
  12. // redirecting to ssl.
  13. $CI->config->config['base_url'] = str_replace('http://', 'https://', $CI->config->config['base_url']);
  14. if ($_SERVER['SERVER_PORT'] != 443) redirect($CI->uri->uri_string());
  15. } else {
  16. // redirecting with no ssl.
  17. $CI->config->config['base_url'] = str_replace('https://', 'http://', $CI->config->config['base_url']);
  18. if ($_SERVER['SERVER_PORT'] == 443) redirect($CI->uri->uri_string());
  19. }
  20. }
  21.  
  22. Esta página não está funcionando
  23. Redirecionamento em excesso por meusite.com
  24. Tente limpar os cookies.
  25. ERR_TOO_MANY_REDIRECTS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement