This one is driving me crazy...
When a file is requested that isn't there, my system will actually find the right "$data" and return it as a 200-- not a 404 error.
Add this to my htaccess file:
ErrorDocument 404 /404.php
In 404.php, actually return a 200 OK with:
header('HTTP/1.1 200 OK', true, 200);
When I use "header('HTTP/1.1 200 OK', true, 200);" I still get a 404 coming back to the browser.
When I use "header('HTTP/1.1 201 OK', true, 200);" it works PERFECTLY-- except I really want to return a 200 not a 201.
Does anyone know how I can solve this problem? I've reproduced this on a couple of different Apache setups so I think anyone else can get the same thing by:
- Setting up htaccess with the ErrorDocument line.
- Setting up 404.php like mine and return something "$data".
- Try browsing to any non-existent page.
- Inspect your http responses and you'll see it's a 404, unless you change the header to 201 instead of 200 (or actually any 2xx instead of 200).
I'm using php 5.3.