質問

I am trying to write a PHP extension that executes some operations for specific requests.

The problem is that, even if the handlers are set correctly for PHP to run, unless the request URL is mapped onto an existing file, it just displays a 'Not Found' error page, skipping the extension code.

Even though this might sound like a bogus usage of PHP, I really want PHP to run, regardless if a PHP script exist or not in the server.

Is there a directive I can use to suppress 'Not Found' error pages for a given regex match, without using redirects? If not, how could I achieve this using redirects?

役に立ちましたか?

解決

Maybe you could use the ErrorDocument directive for that.
But then you'd have to handle all the 404 conditions. The originally requested path is somewhere in the $_SERVER array. So you could use your regex "within" the php script.

edit: the original path is stored in $_SERVER['REQUEST_URI'].
And the php script can send any http status code it wants, 404, 301, 200 whatever; although I don't know what happens with the new cascading definition thingy in apache 2.4 ...

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top