【问题标题】:Force Apache to send 200 instead of 404 in .htaccess强制 Apache 在 .htaccess 中发送 200 而不是 404
【发布时间】:2013-04-01 18:15:33
【问题描述】:

我认为这将是一项简单的任务,但要么我很累,要么只是错过了简单的答案!

我需要一种让 Apache 为任何页面(包括 404 页面)返回 200 的方法。有什么简单的解决办法吗?

这是当前的标头响应:

HTTP/1.1 
404 Article not found 
Date: Mon, 01 Apr 2013 18:05:38 GMT 
Server: Apache P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM" 
Cache-Control: no-cache 
Pragma: no-cache 
Set-Cookie: 440d08f3c65b7f89402db924f5428cbd=ujg53v71nc68fi5pc36rllnd707; path=/ 
Set-Cookie: trcusr=%24%24; expires=Tue, 19-Jan-2038 03:14:07 GMT; path=/ 
Set-Cookie: cltid=103; expires=Tue, 19-Jan-2038 03:14:07 GMT; path=/ 
Set-Cookie: js_vsid=355; expires=Mon, 01-Apr-2013 22:05:38 GMT; path=/ 
Content-Type: text/html; charset=utf-8

【问题讨论】:

    标签: apache http http-headers webserver


    【解决方案1】:

    我会使用 RewriteEngine 将不存在的文件的任何 URL 重写到存在的页面。

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^.*$ file-that-exists.html
    

    未经测试,但应该接近它。

    【讨论】:

      猜你喜欢
      • 2018-06-28
      • 1970-01-01
      • 2011-12-04
      • 1970-01-01
      • 2010-12-01
      • 2017-10-26
      • 1970-01-01
      • 2017-05-19
      • 1970-01-01
      相关资源
      最近更新 更多