浏览器无法加载404页面,但我已经在.htaccess重定向

jum4pzuy  于 2023-01-21  发布在  其他
关注(0)|答案(1)|浏览(95)

我只是做了错误404页面,但浏览器没有加载每一个代码,它只是加载404错误的标题
我已经做了.htaccess和404页在我的本地主机这里是片段

DirectoryIndex  index.html
ErrorDocument 404 error404.html

但是现在,如果我尝试键入localhost/notanypage,在浏览器中显示一个文本:error404.html

m2xkgtsf

m2xkgtsf1#

正如@CBroe在注解中提到的,当指定自定义错误文档时,ErrorDocument指令中使用的 * document * 参数是根相对URL路径,并且必须以斜杠开头,否则它将被视为"string"并输出为纯文本。
例如:

ErrorDocument 404 /error404.html

或者,普通字符串:

ErrorDocument 404 "Sorry, I could not find that file!"

(仅当 * string * 包含 * 空格 * 时,才需要将其用双引号括起来。)
参考:

  • https://httpd.apache.org/docs/current/mod/core.html#errordocument

相关问题