如果我在包含文件夹中有一个页面,但希望header("location: dashboard.php");
从文件夹重定向到主目录,我将如何做到这一点?
我想从两个文件夹中出来到主目录。
你可以这样做(相对寻址):
header("location: ../dashboard.php"); // for one folder
header("location: ../../dashboard.php"); // for two folders
使用超全局 $_SERVER 获取服务器名称并添加路径的其余部分。
$path = $_SERVER['SERVER_NAME'].'/the path';
header("location: " . $path ."/dashboard.php");
因为您将它括在下面的双引号中也是正确的
header("location: $path/dashboard.php");