Simple POST results in empty $_POST

I have an Android app making a post to and API but the $_POST array is empty every time. This was working until some point within the last month. No code on the app or the api has been changed recently.

After sometime trying to figure it out, I set up a simple POST in Postman to a PHP script that prints the $_POST and $_REQUEST arrays. Both are always empty. Doing the same thing on another host provides the anticipated results so I’ve concluded something must have changed on the Dreamhost account. Problem is, I have no idea of what would have changed.

Any suggestions as to what I should be checking?

You might see useful PHP error messages in the Apache error logs (e.g. ~/logs/

Compared the error log before and after a test POST. No change.

I’ve apparently found the cause.

Despite there being no .htaccess file, the www version of the url is redirecting to the non-www version and in doing so, dropping the post data.

The app was posting to the www version. Once that was changed, the problem resolved.

Guess the next question is where/why the redirect is happening and why it is dropping the post data.

Typically, the www vs no-www setup is done in the Panel’s hosting configuration. The odd thing is that you should have seen the redirect page when you made the post request, not an empty result. For example:

$ curl -X POST
<title>301 Moved Permanently</title>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="">here</a>.</p>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.