PHP头部向上移动一个目录? [英] PHP Header move up one directory?

查看:53
本文介绍了PHP头部向上移动一个目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何指定文件重定向到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.phphas 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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆