[ Web 관련 ]/php

php https 체크

BIZLAB 2021. 4. 22. 23:07
<?
$protocol = "http";
if ( (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')  || $_SERVER['SERVER_PORT'] == 443) {		
	$protocol = "https"; 
}
?>
            
<?=$protocol;?>://<?=$_SERVER["HTTP_HOST"];?>/site/url.php

 

<?
$http_host = $_SERVER['HTTP_HOST'];
$request_uri = $_SERVER['REQUEST_URI'];
$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https://" : "http://");
$source_url = $protocol. $http_host . $request_uri;
?>

 

 

 

이게 정확히 반영이 안되네...

$protocol = stripos($_SERVER['SERVER_PROTOCOL'],'https') === true ? 'https://' : 'http://';