简体   繁体   中英

Force Apache to send 200 instead of 404 in .htaccess

I thought this would be a simple task but either I am worng or am just missing the easy answer!

I need a way for Apache to return a 200 for any page including a 404 page. Is there any easy solution?

This is the current header response:

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

I would use RewriteEngine to rewrite any URL to a file that doesn't exist to a page that does.

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

Untested, but that should be close to it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM