【PHP】自動切換網頁至 https

 
<?php
// 要寫在檔案開頭
if (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] === "off") 
{
    $location = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    header('HTTP/1.1 301 Moved Permanently');
    header('Location: ' . $location);
    exit;
}
?>
<html>
...
...
 

沒有留言:

張貼留言