if (condition) { #lol. Some code here } else { header("Location:/");//i'm trying to redirect to the root }
重定向在localhost上完美运行,但在远程服务器上运行不正常.
使用$_SERVER可能更好吗?
即使我选择与具有重定向的文件位于同一目录中的文件,此重定向也不起作用.
希望你帮帮我:)
从
manual:
HTTP/1.1 requires an absolute URI as argument to » Location: including the scheme,hostname and absolute path,but some clients accept relative URIs. You can usually use
$_SERVER['HTTP_HOST']
,$_SERVER['PHP_SELF']
anddirname()
to make an absolute URI from a relative one yourself:
<?PHP /* Redirect to a different page in the current directory that was requested */ $host = $_SERVER['HTTP_HOST']; $uri = rtrim(dirname($_SERVER['PHP_SELF']),'/\\'); $extra = 'mypage.PHP'; header("Location: http://$host$uri/$extra"); exit; ?>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。