tre*_*eng 3 php apache localhost
if (condition)
{
#lol. Some code here
}
else
{
header("Location:/");//i'm trying to redirect to the root
}
Run Code Online (Sandbox Code Playgroud)
重定向在本地主机上完美运行,但在远程服务器上不起作用。也许使用起来更好$_SERVER?即使我选择与重定向文件位于同一目录中的文件,此重定向也不起作用。希望你能帮助我:)
从手册中:
\n\n\n\n\nHTTP/1.1 需要绝对 URI 作为 \xc2\xbb 位置的参数:包括方案、主机名和绝对路径,但某些客户端接受相对 URI。您通常可以使用
\n$_SERVER[\'HTTP_HOST\'],$_SERVER[\'PHP_SELF\']和dirname()自己从相对 URI 中创建绝对 URI:
<?php\n/* Redirect to a different page in the current directory that was requested */\n$host = $_SERVER[\'HTTP_HOST\'];\n$uri = rtrim(dirname($_SERVER[\'PHP_SELF\']), \'/\\\\\');\n$extra = \'mypage.php\';\nheader("Location: http://$host$uri/$extra");\nexit;\n?>\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
14935 次 |
| 最近记录: |