.htaccess redirect all POST request with data to a file

后端 未结 1 561
野的像风
野的像风 2021-01-22 00:11

I have a .htaccess file in a subfolder (www.domain.com/API/) and I need to redirect all POST requests of this subfolder into a file in a subfolder (www.domain.com/A

相关标签:
1条回答
  • 2021-01-22 00:24

    You are using the wrong status code. In a nutshell, the 302 code is not requesting that the browser retransmit all data (the POST request); you need to use the 307 code instead.

    To do this under Apache, update that last rule to end with

    [QSA,L,R=307]

    If you are only interested in the POST data, you don't even need the QSA flag.

    For the gory details, you can see the entire list of HTTP status codes and their meanings here. The reason the 302 code is not functioning the way you want it to is explicitly called out in on the protocols page as follows (emphasis mine)

    Note: RFC 1945 and RFC 2068 specify that the client is not allowed to change the method on the redirected request. However, most existing user agent implementations treat 302 as if it were a 303 response, performing a GET on the Location field-value regardless of the original request method. The status codes 303 and 307 have been added for servers that wish to make unambiguously clear which kind of reaction is expected of the client.

    0 讨论(0)
提交回复
热议问题