Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 0.44 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Trouble redirecting to HTTPS with PHP
  2. if (!isset($_SERVER['HTTPS']) || !$_SERVER['HTTPS']) {  
  3.     $url = 'https://www.mysite.php';
  4.     header("location: ". $url);
  5.     exit();
  6. }
  7.        
  8. if (!isset($_SERVER['HTTPS']) OR !$_SERVER['HTTPS']) {
  9.        
  10. if (!isset($_SERVER['HTTPS']) AND !$_SERVER['HTTPS']) {
  11.        
  12. if(empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on") {
  13.     header("Location: https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
  14. }