开发者

When the target of a .NET HttpModule RewritePath call is a PHP file the $_POST array is empty

开发者 https://www.devze.com 2022-12-30 17:08 出处:网络
We have an application running on IIS 6 which uses a custom HttpModule to rewrite urls. This works great (well done us) except in the case where the Context.RewritePath destination is a .php file. The

We have an application running on IIS 6 which uses a custom HttpModule to rewrite urls. This works great (well done us) except in the case where the Context.RewritePath destination is a .php file. The php fil开发者_运维技巧e is executed as expected, however the $_POST collection is empty meaning it cannot access any forms which are submitted to rewritten urls. The problem does not exist when rewriting to .aspx files as the Request.Form collection is fine.

My question therefore has two parts: Why is the $_POST collection not being populated? Is there a way to ensure that the .php $_POST collection is correctly populated after a rewrite?

I don't have much to show in the way of code. There's just a simple:

context.RewritePath(newPath);

once the HttpModule has figured out where to send the request.

Edit: Interestingly, if I do var_dump(file_get_contents('php://input')); in the PHP file (method described here) the contents of the form is displayed. So the data is reaching the PHP script but not the $_POST array.


Redirecting turns a POST action into a GET action, which means that any POST parameters initially sent are lost. You'll have to use a backchannel method (e.g. sessions) in order to pass the variables along.

0

精彩评论

暂无评论...
验证码 换一张
取 消