2020-12-18

【PHP】自動切換網頁至 https

  1.  
  2. <?php
  3. // 要寫在檔案開頭
  4. if (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] === "off")
  5. {
  6. $location = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
  7. header('HTTP/1.1 301 Moved Permanently');
  8. header('Location: ' . $location);
  9. exit;
  10. }
  11. ?>
  12. <html>
  13. ...
  14. ...
  15.  

沒有留言:

張貼留言