我正在尝试使用xampp中的标头位置重定向页面,但它无法正常工作并重定向到localhost / dashboard
我在localhost中使用以下代码进行简单的重定向,我将我的网站放在htdocs / test /和index.html和index.php中的文件中,index.php代码如下
<?php
header("Location:/index.html");
?>
当我尝试访问http://localhost/test/index.php时,它不会访问localhost / test / index.html 但它重定向到http://localhost/dashboard/
答案 0 :(得分:1)
检查你的php.ini文件中output_buffering = On;然后使用此代码重定向到index.html
<?php
ob_start();
if (headers_sent()) {
die("Redirect failed.");
}
else{
exit(header("Location: index.html"));
}
?>
&#13;
您可以从此处获取ob_start的详细信息http://php.net/manual/en/function.ob-start.php
答案 1 :(得分:0)
我知道你的问题,这应该解决它。
<?php
header('Location: ./index.html');
?>
其中./
代表当前目录
答案 2 :(得分:-1)
尝试:
<?php
echo "<script type=\"text/javascript\" language=\"javascript\">
window.location.replace(\"index.html\");
</script>";
?>