<?php
if ($_SERVER['HTTPS'] === 'off') // 如果不是以https开头
echo 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
else
echo 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
?>
<?php
if ($_SERVER['HTTPS'] === 'off') // 如果不是以https开头
echo 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
else
echo 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
?>