如何在php中获取当前的完整URL?
实施例。完整网址:www.topclinique.ma/list-cliniques.php?t = cliniques& s = 0& c =卡萨布兰卡
答案 0 :(得分:3)
您可以使用
$current_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
答案 1 :(得分:0)
试试这个:
if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
$protocol = 'https://';
}
else {
$protocol = 'http://';
}
$current_link = $protocol.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
echo $current_link;