0

I try to transfer website from old server to new, and stucked with one problem. PHP/JS code on both servers is the same, but on new server it is not working - $_POST data are empty in AJAX-request.

Some details:

Old server: Debian 7, Nginx + Apache(mod_php 7.4)

New server: Ubuntu 22.04, Nginx 1.18.0 + Apache 2.4.52 (mod_php 7.4)

Requested address /basket/add/. It isn't exist, .htaccess contains rule ErrorDocument 404 /404.php

404.php contains router for logical url's, which should read $_POST and add product to basket. I add var_dump($_POST); at the very beginning of 404.php, but $_POST always empty array().

When the same request is going to existing file (not to 404.php), $_POST are filled normally.

So, the problem is in .htaccess directive ErrorDocument 404 /404.php. Old server see $_POST in 404.php correctly, but new server - no.

I really can't understand, why it happens. Any ideas?

Ipromo
  • 1
  • How does Nginx fit into this scenario? Using `ErrorDocument` in that way is a bit "hacky" and means you need to explicitly override the HTTP status on every request. Why are you doing it that way and not using mod_dir `FallbackResource` or explicitly rewriting the request using mod_rewrite? – MrWhite Aug 11 '22 at 17:29
  • Have you confirmed that the request that reaches your `/404.php` file is still a POST request or is it being _converted_ to GET (hence why the POST data is lost)? – MrWhite Aug 11 '22 at 17:33
  • Nginx is proxy (give static files and proxying php to apache). POST definetely not converted to GET. I also var_dump $_REQUEST and $_GET, they are empty too. So, request data is lost completely. – Ipromo Aug 11 '22 at 17:58
  • remember that you need to install and activate any modules on the new apache server... this is a common problem and issue that people forget about to solve – djdomi Aug 13 '22 at 16:08

0 Answers0