我怎么能取代的Apache HTTP code 404到200 [英] How can I replace Apache HTTP code 404 to 200

查看:258
本文介绍了我怎么能取代的Apache HTTP code 404到200的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不希望网站的阿帕奇返回任何HTTP code 404,

原因是评审委员会将扫描所有的网站,

很多JavaScript的链接和某些事件会造成404 code,

其实,这些链接是有效的,但该检查将误判错误。

所以,我想prevent apache的返回HTTP code 404,

如何配置Apache的HTTP返回200鳕鱼,而不是404和显示我的定义错误页?

I don't want the apache of a website return any HTTP code 404,
the reason is that the accreditation council will scan all the website,
many javascript links and some incidents will cause the 404 code,
in fact, those links are valid but that checker will misjudge error.
So, i want to prevent the apache to return HTTP code 404,
How can I configure apache return HTTP cods 200 instead of 404 and show my define error page?

推荐答案

来源:的http://www.askapache.com/htaccess/apache-status-$c$c-headers-errordocument.html


  1. 创建一个名为404的主网站目录空白文件..可以为空。

  2. 添加到您的.htaccess文件:

  1. Create a blank file in your main web directory named 404.. can be blank.
  2. Add this to your .htaccess file:

Redirect 200 /404
ErrorDocument 404 /404


这将改变了Apache的ErrorDocument到/ 404文件。但是,重定向行导致的/ 404请求发出一个200 OK响应,而不是404。

That will change the Apache ErrorDocument to the /404 file. But the Redirect line causes requests for /404 to issue a 200 OK response instead of a 404.

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

If that doesn't work it is due to rewrites no doubt. So if that's the case add this under those first 2 lines but above any other rewrite lines in your .htaccess file:

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]

在详细解释的:<一href=\"http://www.askapache.com/htaccess/apache-status-$c$c-headers-errordocument.html#Automate_ErrorDocument_Triggering\" rel=\"nofollow\">http://www.askapache.com/htaccess/apache-status-$c$c-headers-errordocument.html#Automate_ErrorDocument_Triggering

这篇关于我怎么能取代的Apache HTTP code 404到200的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆