//主动判断是否HTTPS
function isHTTPS()
{
if (defined('HTTPS') && HTTPS) return true;
if (!isset($_SERVER)) return FALSE;
if (!isset($_SERVER['HTTPS'])) return FALSE;
if ($_SERVER['HTTPS'] === 1) { //Apache
return TRUE;
} elseif ($_SERVER['HTTPS'] === 'on') { //IIS
return TRUE;
} elseif ($_SERVER['SERVER_PORT'] == 443) { //其他
return TRUE;
}
return FALSE;
}
$protocol=isHTTPS() ? 'https://' : 'http://';
$url = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
echo $url;//输出完整的url如果本文对你有帮助,欢迎打赏本站

支付宝扫码打赏
微信扫码打赏
