为什么我的Web服务器软件不允许PUT和DELETE请求? [英] Why does my web server software disallow PUT and DELETE requests?

查看:5658
本文介绍了为什么我的Web服务器软件不允许PUT和DELETE请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现REST协议,并且已经意识到我试图调试我的网络服务器不允许 PUT 请求。

I am trying to implement a REST protocol and have realized in trying to debug that my web server is disallowing the PUT request.

我已通过运行测试并进一步确认:

I have tested and confirmed this further by running:

curl -X PUT  http://www.mywebserver.com/testpage

我的网络服务器返回 403 - Forbidden error

DELETE 也是如此,其中 POST GET 一切都很好。

The same happens for DELETE, where as for POST and GET everything is fine.

我想知道这是否是一个常见问题谁使用REST遭遇以及解决方法可能是什么?

I am wondering if this is a common issue that those who use REST encounter and what the work-around might be?

我是否可以对 .htaccess 档案?或者我是否需要修改协议以在POST查询字符串中设置隐藏变量_method?

Could I make a simple change to an .htaccess file? Or do I need to modify the protocol to set a hidden variable "_method" in the POST query string?

推荐答案

通常是Web服务器将被配置为阻止除GET和POST之外的任何内容,因为
99%的时间它们都是需要的,而且假设请求是其中之一,应用程序中的
过去一直存在问题。

Often web servers will be configured to block anything except GET and POST since 99% of the time they're all that are needed and there have been problems in the past with applications assuming the requests were one of those two.

你没有说它是哪个服务器,但是,例如,你可以告诉Apache哪些
方法允许使用该指令:

You don't say which server it is but, for example, you can tell Apache which methods to allow with the directive:

例如:

<Limit POST PUT DELETE>
  Require valid-user
</Limit>

听起来好像一些有用的系统管理员用它来阻止非GET / POST

It sounds like maybe some helpful sysadmin has used this to block non GET/POST

您可以尝试 .htaccess

<Limit GET POST PUT DELETE>
  Allow from all
</Limit>

(我不是apache的专家,这可能不完全正确)

(I'm not an expert at apache, this may not be exactly correct)

这篇关于为什么我的Web服务器软件不允许PUT和DELETE请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆