Let apache handle 404 error when deemed appropriate by PHP?
Asked Answered
T

2

2

I perfectly know how to create a custom 404 page in PHP, however I'm wondering if there's a way to give back control to to apache and let it produce the proper 404 page, sending right headers, etc. when my logic says so?

I'm looking at some apache specific functions but can't seem to find anything appropriate. Is that really just not possible? I recall something similar available to e.g. mod_perl by having full access to apache internals, where's that equivalent in PHP?

Tephrite answered 30/9, 2009 at 22:58 Comment(0)
T
1

My research so far led me to the conclusion that it's not possible to delegate back to Apache from within mod_php like some other technologies, e.g. mod_perl, allow.

Tephrite answered 12/10, 2009 at 20:47 Comment(0)
R
0

I'm not sure you can do what you want to do exactly, but one of your requirements can be met by php, and well, apart from ... I don't really see any other ones.

You can send the correct type of header using the header() function. In my code I usually use the one below.

header("HTTP/1.0 404 Not Found");
echo "sorry, page not found...";

See function.header.php in the php manual for more details.

Rosabelle answered 30/9, 2009 at 23:18 Comment(2)
I see, sorry. Perhaps clarifying more why you want apache to do it, and not using examples of things you can already do from php might help? PHP can produce a proper 404 page, so there is confusion in your request in that way. Wish I could help more, but I know of no way to return the logic back to apache without doing something dumb like header requesting to a url not handled by php.Rosabelle
I wanted to take advantage of Apaches mechanism which generates additional headers for 404 pages which I would have to manually add, which I'm not fond of. Seems PHP simply doesn't support this kind of thing.Tephrite

© 2022 - 2024 — McMap. All rights reserved.