Please take a look at the following .htaccess
ErrorDocument 404 /404/
RewriteEngine On
RewriteRule (.*) index.php [L]
With this setup, I am using header('HTTP/1.1 404 Not Found'); in PHP to redirect to the error handling page and send the appropriate HTTP status code. The correct 404 status code is sent, but the browser shows a blank page and the access log shows "GET /invalid-url/ HTTP/1.1" 404 -
Can anyone tell me how to make ErrorDocument work with Apache URL rewrites?
I guess the answer to my question is: I don’t need to.
What I was trying to accomplish was a “404 redirect”. That is, when requesting an invalid URL, redirect to the 404 document along with setting the “Status 404 Not found” header.
And I am not sure that’s something I want, because invalid URLs should be marked with the 404 status code, not redirected.