Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 更改自定义404错误页面_Apache_Http Status Code 404 - Fatal编程技术网

Apache 更改自定义404错误页面

Apache 更改自定义404错误页面,apache,http-status-code-404,Apache,Http Status Code 404,不久前,我把我的404错误页面改为我网站的主页。(我真傻,但我对这方面还不熟悉,当时这似乎是个好主意。) 问题是,我忘了我是怎么做到的。我曾经尝试过文本模式CMS,我想我是在CMS中尝试的,但我不记得是怎么做的 现在,我不再使用CMS(但数据库仍然存在),我创建了一个更具描述性的错误页面,并更新了.htaccess文件,但行为没有改变——仍然会返回旧的错误(坏)页面。我在.htaccess文件中尝试了以下操作,但均无效 ErrorDocument 404 default ErrorDocumen

不久前,我把我的404错误页面改为我网站的主页。(我真傻,但我对这方面还不熟悉,当时这似乎是个好主意。)

问题是,我忘了我是怎么做到的。我曾经尝试过文本模式CMS,我想我是在CMS中尝试的,但我不记得是怎么做的

现在,我不再使用CMS(但数据库仍然存在),我创建了一个更具描述性的错误页面,并更新了.htaccess文件,但行为没有改变——仍然会返回旧的错误(坏)页面。我在.htaccess文件中尝试了以下操作,但均无效

ErrorDocument 404 default
ErrorDocument 404 http:/www.mysite.com/404.shtml
ErrorDocument 404 /404.shtml
任何帮助都将不胜感激。谷歌网站管理员工具报告54个“软404”错误,我必须修复


-谢谢

我希望这样的404软页面是错误页面,服务器响应代码是200,而不是404

这在一定程度上取决于您在服务器上使用的软件。我认为您的脚本404.shtml返回了错误的响应代码。到目前为止,您需要编辑该文件,使其返回响应代码404

在PHP中,您可以通过以下方式实现:

header("Not Found", 404, true);
请注意,该行必须位于任何输出之前