[英]Redirecting a page Based on URL Value
I am trying to redirecting my register page to https://
based on parse url value.Below is my code 我正在尝试基于解析URL值将我的注册页面重定向到
https://
。下面是我的代码
$url = $current_url="//".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$parts = parse_url($url);
parse_str($parts['query'], $query);
if ($query['view']=='register') {
$porthttp = "https://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
header("Location: " . $porthttp);
exit();
}
But it is giving error ' server is redirecting the request for this address in a way that will never complete. 但这给了错误, 服务器正在以永远无法完成的方式重定向对该地址的请求。 '
“
what's wrong i am doing? 我在做什么错?
You are redirecting on same page which you accessing so it will not work. 您正在访问的同一页面上进行重定向,因此它将无法正常工作。 Ie http://localhost/demo/test.php?view=register and you are checking condition like if ($query['view']=='register') {} then you are redirecting on same page using $_SERVER['REQUEST_URI'] so it will go to infinite loop.
即http://localhost/demo/test.php?view = register ,您正在检查条件,例如是否($ query ['view'] =='register'){},然后使用$ _SERVER []在同一页面上进行重定向[ 'REQUEST_URI'],因此它将进入无限循环。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.