PHP头部向上移动一个目录? [英] PHP Header move up one directory?
问题描述
如何指定文件重定向到PHP中当前文件上一级的文件?以下是我的示意图:
-landing.html
-ajax
-checkLogin.php
checklogin.php
包含以下代码:
标题(location:dashboard.html);
从 landing.php
是上面的一级。我怎样才能选择一个文件上面的目录?我已经尝试了 .. landing.php
,但好像它只会记录文件名。
考虑如果你移动 checkLogin.php
以下任何一个都不会有问题。
header(Location:/landing.html);
//或
标题(位置:http://www.example.com/landing.html);
How do I specify a file redirect to a file one level above the current file in PHP? Here is my schematic so far:
-landing.html
-ajax
-checkLogin.php
checklogin.php
has the following code in it:
header("location:dashboard.html");
This obviously doesn't work since landing.php
is one level above. How can I select a file one directory above? I already tried ..landing.php
, but seems like it will only take filenames.
You should really use absolute paths (at least relative to your document root).
Consider if you move checkLogin.php
a directory deeper…
Any of the follow won't have a problem.
header("Location: /landing.html");
// or
header("Location: http://www.example.com/landing.html");
这篇关于PHP头部向上移动一个目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!