Apache "File not found." 而不是 404. 错误文档

Apache "File not found." instead of 404. error document

我想设置一个自定义的 404 错误文档,但是我遇到了问题!

首先,我的 .htaccess 中有两个 RewriteRules:

RewriteRule ^([^/.]+)/([^/.]+)/([^/.]+)/?$ //.php?lang= [L]
RewriteRule ^([^/.]+)/([^/.]+)/([^/.]+)/([^/.]+)/?$ ///.php?lang= [L]

所以我的 URL 看起来像:/de-de/page/other/stuff 并打开 /page/other/stuff.php?lang=de-de

现在是时候设置我自己的错误文档了: 错误文档 404 /404.php

如果“/de-de/page/other/”中有错误,例如“/de-de/wrong/page/”,我就成功获取了错误文档。但是,如果 php 文件名有误(例如 "wrong-stuff" 而不是 "stuff"),我只会收到消息 "File not found." 而不是我的错误文档。

怎么了?我能做些什么来修复它?

感谢您的帮助!

AuthType Basic
AuthName "Password Protected Area"
AuthUserFile /var/www/vhosts/<domain>/development/tests/demo.<domain>/.htpasswd
Require valid-user

<IfModule mod_rewrite.c>
    RewriteEngine on        
    RewriteCond %{HTTPS} !=on
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/ [R,QSA]
</IfModule>



RewriteRule ^([^/.]+)/([^/.]+)/([^/.]+)/?$ //.php?lang= [L]
RewriteRule ^([^/.]+)/([^/.]+)/([^/.]+)/([^/.]+)/?$ ///.php?lang= [L]

ErrorDocument 404 /404.php 

Apache 错误日志:

[404] GET /de-de/support/support/fdfssdf HTTP/1.0
AH01071: Got error 'Primary script unknown\n'

使用RewriteCond检查php文件是否存在:

RewriteCond %{REQUEST_URI} ^/([^/.]+)/([^/.]+)/([^/.]+)/?$
RewriteCond %{DOCUMENT_ROOT}/%2/%3.php -f
RewriteRule ^ /%2/%3.php?lang=%1 [L]

RewriteCond %{REQUEST_URI} ^/([^/.]+)/([^/.]+)/([^/.]+)/([^/.]+)/?$
RewriteCond %{DOCUMENT_ROOT}/%2/%3/%4.php -f
RewriteRule ^ /%2/%3/%4.php?lang=%1 [L]