[英]PHP URL Redirect (Getting full URL + GET)
How would I get just the last part to my URL? 我如何才能获得我的URL的最后一部分?
Ex. 防爆。
?page=home&optional=lol
I am not familiar with any of the server commands, so much help would be appreciated. 我不熟悉任何服务器命令,非常感谢。 Also note that the GET variables are dynamic and will be different. 另请注意,GET变量是动态的,并且会有所不同。
QUERY_STRING服务器变量应该是您正在寻找的:
$_SERVER['QUERY_STRING'];
Getting the full URL of the page is a bit complicated, but not very: 获取页面的完整URL有点复杂,但不是很多:
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
}
else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
$parsed_url = parse_url($pageURL);
$qs = $parsed_url['query']; //query string, this is the ? part of the URL
这可以在$_SERVER['REQUEST_URI']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.