强制Apache在.htaccess文件中发送200而不是404

强制Apache在.htaccess文件中发送200而不是404,apache,.htaccess,mod-rewrite,redirect,Apache,.htaccess,Mod Rewrite,Redirect,我需要强制Apache发送200 OK而不是404 in。我不知道这是否可能。我从一篇文章中找到了下面的文字,但它不起作用,我不知道为什么 发件人: 在主web目录中创建一个名为404的空白文件。。可以是空白。 将此添加到.htaccess文件: Redirect 200 /404 ErrorDocument 404 /404 Options FollowSymLinks ExecCGI RewriteEngine On RewriteBase / # If the requested f

我需要强制Apache发送200 OK而不是404 in。我不知道这是否可能。我从一篇文章中找到了下面的文字,但它不起作用,我不知道为什么

发件人:

在主web目录中创建一个名为404的空白文件。。可以是空白。 将此添加到.htaccess文件:

Redirect 200 /404
ErrorDocument 404 /404
Options FollowSymLinks ExecCGI

RewriteEngine On
RewriteBase /

# If the requested file doesnt exist
# and if the requested file is not an existing directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^[^4]* /404 [L,S=4000]
这将把Apache ErrorDocument更改为/404文件。但是重定向行导致/404请求发出200OK响应,而不是404

如果这不起作用,毫无疑问是由于重写。因此,如果是这种情况,请将其添加到.htaccess文件中前两行的下面,但任何其他重写行的上面:

Redirect 200 /404
ErrorDocument 404 /404
Options FollowSymLinks ExecCGI

RewriteEngine On
RewriteBase /

# If the requested file doesnt exist
# and if the requested file is not an existing directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^[^4]* /404 [L,S=4000]

详细说明如下:

为了发送200状态而不是通常的404,您可以使用以下重写规则:

ErrorDocument 404 default
RewriteEngine On
RewriteBase /

RewriteRule ^404\.html/?$ - [L]

# If the requested file doesnt exist
# and if the requested file is not an existing directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . 404.html [L]

它不起作用了。。。我把同样的代码从上面。。。它仍然说找不到404…这意味着您仍然有
errordocument404
行。将其注释掉,并删除任何其他规则,如
重定向
或任何其他规则。该文件中没有其他规则不在上述目录行中。Aluminikumskicamci.co.rs/11/22/some-no-exist-file.htm它仍然不起作用,我是否应该为404放置一些错误重定向文件或其他东西,也许它没有再次显示404的位置……好的,
/404
现有文件吗?它必须是现有的文件才能工作。