如何指定文件重定向到PHP上当前文件上一级文件?这是我到目前为止的原理图:
-landing.html
-ajax
-checkLogin.php
Run Code Online (Sandbox Code Playgroud)
checklogin.php其中包含以下代码:
header("location:dashboard.html");
Run Code Online (Sandbox Code Playgroud)
这显然不起作用,因为landing.php是上面的一个级别.如何在上面的一个目录中选择文件?我已经尝试过..landing.php,但似乎只会采用文件名.
您应该使用绝对路径(至少相对于您的文档根目录).
考虑一下你是否checkLogin.php更深入地移动目录......
以下任何一个都不会有问题.
header("Location: /landing.html");
// or
header("Location: http://www.example.com/landing.html");
Run Code Online (Sandbox Code Playgroud)
接受的答案将带您到域的根目录,而不是指定的 1 个文件夹。
向上移动一个文件夹:
header("Location: ../landing.html");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12738 次 |
| 最近记录: |