0

I'm trying to develop a handler for virtual paths in Apache 2.4.2 and PHP 5.4.5 (loaded as a module), using the ErrorDocument directive:

<Directory "...">
    ...
    ErrorDocument 404 /handler.php
    ...
</Directory>

As far as the used method is GET or HEAD, it all works like a charm. Troubles come when the method is POST.

When using POST, in my test PC I manage to get the input stream via file_get_contents('php://input'), even when the Content-Type header is set to multipart/form-data. In the server PC, the content is always empty, even when the type is application/x-www-form-urlencoded.

I'm trying to get the raw POST data because $_POST and $_FILES are empty when the script is the result of this kind of redirection.

Is there something I'm missing? Maybe some different setting in the httpd.conf file? The php.ini file is the same. I just don't know where to begin.

UPDATE: it seems the difference was due to the action attribute of the <form> element I was using for testing purposes. Looks like the script is able to get the raw POST data when the action is set to a .php file and it's located in the root directory.

I guess this has something to do with the AddHandler directive used in the httpd.conf file.

MaxArt
  • 22,200
  • 10
  • 82
  • 81
  • After server redirecting there is no post data available. – el Dude Nov 18 '12 at 22:40
  • @EL2002 Too bad. But it seems that in *some* cases the raw post data is actually available. But it also seems that I can't rely on that... – MaxArt Nov 19 '12 at 08:56
  • see http://stackoverflow.com/questions/10396886/how-to-get-post-query-when-404-redirected-through-haccess which explains how to use mod_rewrite to do this – user340140 Apr 24 '14 at 00:28

0 Answers0