Cakephp 3:为 put 提供 403 禁止错误
Cakephp 3 : Giving 403 Forbidden error for put
我正在使用cakephp 3.3.2 版本和5.6 php 版本。
我的编辑操作看起来像
public function edit($id = null) {
$country = $this->Countries->get($id, [
'contain' => []
]);
if ($this->request->is(['patch', 'post', 'put'])) {
$country = $this->Countries->patchEntity($country, $this->request->data);
if ($this->Countries->save($country)) {
$this->Flash->success(__('The country has been saved.'));
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('The country could not be saved. Please, try again.'));
}
}
$this->set(compact('country'));
$this->set('_serialize', ['country']);
}
此代码在本地主机上运行良好,但在我的真实主机(使用共享主机)中,当我要编辑某些内容时,它给了我 403 禁止错误。然后我用 postman 来检查。然后我看到它对 get 和 post 工作正常,但给 403 Forbidden error for put。 php 或 cakephp 中有没有额外的设置来解决这个问题?
你说它在本地主机上工作所以它可能是服务器问题..
检查这个批准的答案-
Why does my web server software disallow PUT and DELETE requests? 回答
我正在使用cakephp 3.3.2 版本和5.6 php 版本。
我的编辑操作看起来像
public function edit($id = null) {
$country = $this->Countries->get($id, [
'contain' => []
]);
if ($this->request->is(['patch', 'post', 'put'])) {
$country = $this->Countries->patchEntity($country, $this->request->data);
if ($this->Countries->save($country)) {
$this->Flash->success(__('The country has been saved.'));
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('The country could not be saved. Please, try again.'));
}
}
$this->set(compact('country'));
$this->set('_serialize', ['country']);
}
此代码在本地主机上运行良好,但在我的真实主机(使用共享主机)中,当我要编辑某些内容时,它给了我 403 禁止错误。然后我用 postman 来检查。然后我看到它对 get 和 post 工作正常,但给 403 Forbidden error for put。 php 或 cakephp 中有没有额外的设置来解决这个问题?
你说它在本地主机上工作所以它可能是服务器问题.. 检查这个批准的答案- Why does my web server software disallow PUT and DELETE requests? 回答