Xampp 错误 "Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."

Xampp Error "Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."

您好,我正在为我的站点(不是 wordpress)试用 apache htaccess。我想生成自定义 404 错误,所以我在 .htaccess 文件中添加了以下内容:

ErrorDocument 404 /404.php

我的文件结构是

/htdocs
       /some-dir
                /.htaccess
                /404.php

当我随机访问 URL 时出现错误:

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

ErrorDocument 404 /404.php

ErrorDocument 指令采用文档根相对路径 URL-路径,因此从您的文件结构来看,这应该是:

ErrorDocument 404 /some-dir/404.php

参考: