I have an UBUNTU server with Apache. POST request to specific endpoint on this server is automatically redirected by Apache to a GET request if the URL does not have a trailing slash
On that path, the server has a index.php
file that basically gets the body and inserts into a mySQL dB.
https://www.myserver.com/py/order/ORDER-0001
--> Does not work
Apache access.log:
186.139.yy.xx - - [04/May/2023:07:42:18 -0300] "POST /py/order/ORDER-0001 HTTP/1.1" **301** 5380 "-" "PostmanRuntime/7.32.2"
186.139.yy.xx - - [04/May/2023:07:42:18 -0300] "**GET** /py/order/ORDER-0001/ HTTP/1.1" 200 236 "https://www.myserver.com/py/order/ORDER-0001" "PostmanRuntime/7.32.2"
However, https://www.myserver.com/py/order/ORDER-0001
--> Works perfectly fine
Apache access.log:
186.139.yy.xx - - [04/May/2023:07:49:28 -0300] "POST /py/order/ORDER-0001/ HTTP/1.1" 200 4964 "-" "PostmanRuntime/7.32.2"
I have tried many things as mentioned on these but still nothing works for me:
The latest I've tried is "forcing" a trailing slash with a 307 redirect. I have added this snippet on apache2.conf
<Directory /var/www/html/py/order/ORDER-0001>
AllowOverride All
Require all granted
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*[^/])$ /$1/ [L,R=307]
</Directory>
Can anyone please help on this?