Yii2 REST API IIS对象已移动

我使用Yii2 REST与ActiveController来创build新的Pessoa() ,在Apache上工作正常,但在IIS 8上发生错误。

有谁知道IIS中的任何configuration?

请求

Request URL:http://10.192.1.145/api/pessoa Request Method:POST Status Code:201 Created Remote Address:10.192.1.145 Referrer Policy:no-referrer-when-downgrade 

响应

 <head><title>Document Moved</title></head> <body><h1>Object Moved</h1>This document may be found <a HREF="http://10.192.1.145/api/pessoa/45">here</a></body>{"id":"21"} 

我有类似的问题。 这似乎与FastCGI有关。 不确定。 我知道在将响应头设置为201后面的http状态代码( 源代码中的这一行 )时会发生这种情况。 如果您有权访问服务器,请尝试以下解决方案

W7临IIS 7.5覆盖PHP位置:标题(已解决)

在我的情况下,我只有FTP访问服务器,所以我重写了创建操作,如下面强制200状态代码而不是201:

 public function actions() { $actions = parent::actions(); unset($actions['create']); return $actions; } public function actionCreate() { $model = new Pessoa(); $model->load(Yii::$app->getRequest()->getBodyParams(), ''); if ($model->save() === false && !$model->hasErrors()) { throw new serverErrorHttpException('Failed to update the object for unknown reason.'); } return $model; }