We need an ErrorDocument 404 php error handler for bad links including dropped pages on a web site or requests for a url that has never been on the site. Note that mod_rewrite is in heavy use on the site.
Specification:
Redirection to a simple php page, i.e. [login to view URL] in the root directory of the site to be handled by simple .htaccess code. (ErrorDocument 404 /[login to view URL]).
We must return a 404 error to the requesting source AND display html code from within the [login to view URL] handling. Please note that we will replace test html code with a smarty include directive to our error page from within Err404.php.
A primary specification is that code 200 is NOT sent to a requestor because error redirection forwards a request to our error page, i.e. the url may be bad but a resulting page does exist due to error handling and therefore the request was satisfied without a 404 error.
Mod_rewrite is used extensively on this site from .htaccess, and to some extent from [login to view URL] and the code has to handle redirection for rewritten urls that no longer exist.
Example of desired handling:
There is an existing .htaccess rule for [login to view URL] although it has been deleted.
htaccess snippet:
RewriteRule ^[login to view URL](&xid=[0-9a-f]*)?$ [login to view URL];%1 [L]
A request for [login to view URL] can return 200 OR return 404 AND it must cause redirection to the error page called by Err404.php.
Another example:
[login to view URL] - a url that never has existed on the site is requested.
Your code MUST result in both a 404 code return AND redirection from [login to view URL] to a valid page.