我有一个文件secret.php
其中包含在index.php
我想在有人尝试访问时显示 404 错误页面secret.php
直接地。但
header("Location: this_site_certainly_does_not_exist");
in secure.php
不是一个解决方案,因为我想要用户输入的 URL(例如example.com/secret.php
) 在显示错误页面时在浏览器的 URL 栏中可见,而不是重定向。
你可以用标题来做到这一点。
header("HTTP/1.0 404 Not Found");
然后你可以使用例如添加你的404页面readfile
method.
header("HTTP/1.0 404 Not Found");
echo "<h1>404 Not Found</h1>";
echo "The page that you have requested could not be found.";
exit();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)