Let apache handle 404 error when deemed appropriate by PHP?

僤鯓⒐⒋嵵緔 提交于 2019-12-11 02:39:49

问题


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?


回答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.




回答2:


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.



来源:https://stackoverflow.com/questions/1501094/let-apache-handle-404-error-when-deemed-appropriate-by-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!