【问题标题】:Apache put : The requested method PUT is not allowed for the URLApache put:请求的方法 PUT 不允许用于 URL
【发布时间】:2015-06-18 20:08:59
【问题描述】:

我试图在我的 apache 2.2 上允许“put”方法,但是我尝试过什么(Limit、LimitExcept ...),
我总是收到以下错误:

405 Method Not Allowed
The requested method PUT is not allowed for the URL

这是我的 http.conf :

<VirtualHost *:80>
    ServerName example.com:80    
    DocumentRoot "D:/test"
    Include "D:/conf/httpd.conf"
    <Directory />
        Order Allow,Deny
        Allow From All
        Options Indexes FollowSymLinks MultiViews
        <LimitExcept GET PUT POST DELETE>
            Order allow,deny
            Allow from all
        </LimitExcept>
    </Directory> 
</VirtualHost>

更新: 我阅读了一些相关的帖子,如下所示:

http://stackoverflow.com/questions/2934554/how-to-enable-and-use-http-put-and-delete-with-apache2-and-php  

但我没有任何脚本 php 或 cgi。
我只想用 mod_rewrite 将 http 调用(get、post、put delete ...)重定向到模拟文件:

RewriteCond %{REQUEST_URI} ^/maincall/customer
RewriteCond %{REQUEST_METHOD} PUT
RewriteRule /maincall/customer %{DOCUMENT_ROOT}/mockfolders/PUT/data.json

【问题讨论】:

    标签: apache mod-rewrite put http-status-code-405


    【解决方案1】:

    我在使用邮递员进行服务器测试时发现了这个问题。实际上这个问题发生是因为你输入了一个错误的 URL。尝试修复您点击的 URL。它适用于我的问题

    【讨论】:

      【解决方案2】:

      我找到了解决办法:

      • 安装 perl 以创建 cgi 脚本
      • 在 httpd.conf 中定义以下规则:

        AddHandler cgi-script .pl
        RewriteCond %{REQUEST_URI} ^/my/url
        RewriteCond %{REQUEST_METHOD} PUT
        RewriteRule /my/url "C:/Apache/Apache2.2/cgi-bin/myurlput.pl"

      成功了

      【讨论】:

      • 这是否意味着 Apache 无法在没有额外脚本的情况下处理 PUT 文件请求?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-23
      • 1970-01-01
      • 2021-10-16
      • 2018-02-19
      相关资源
      最近更新 更多