使用put方法时的Apache 301状态

时间:2014-03-04 13:12:56

标签: php apache backbone.js put http-status-code-403

开发一个简单的主干和php应用程序,但在服务器上我得到403错误

每当我使用put方法

当然,当使用更传统的方法如get和post时,我没有遇到任何问题。

任何人都可以建议调整哪些特定设置,因为在另一台服务器上它运行良好。

我的嫌疑人

  1. apache配置
  2. php配置
  3. 提前致谢。

    代码示例

    PHP文件

    $this -> method = $GLOBALS['_SERVER']['REQUEST_METHOD'] ;
    switch ( $this -> method ) { 
    case ( 'POST' ) : 
        foreach ( $_POST as $k => $v ) 
            $data -> $k = $v ;
        $data = $this -> save ($data) ;
        $this -> output( $data ) ;
        break 
    case ( 'PUT' ) : 
        $putdata = fopen("php://input", "r");
        while ($d = fread($putdata, 1024))
            $data .= $d ;
    
        $data = json_decode( $data ) ; 
        $data = $this -> save ($data) ;
        $this -> output( $data ) ;                              
        break ;
    case ( 'DELETE' ) :
        $data = $this -> delete($data) ;
        $this -> output( $data ) ;                              
        break ;
    
    case ('GET') :
    default:
        $data = $this -> retrieve () ;
        $this -> output( $data ) ;                              
        break ;
    }
    

    请注意,使用jquery ajax生成xhr请求时,骨干不需要使用表单

    arguments: {
        0: {
          contentType: "application/json"
          data: { 
            "id":0,
            "dat":"10-03-2014",
            "title":"Bunk bed",
            "current":false,
            "enrole":[],
            "result":"",
            "starts":{"m":{},"f":{}},"sex":"m"} 
      }
          dataType: "json"
          emulateHTTP: false
          emulateJSON: false
          error: function (resp) { ... }
          parse: true
          processData: false
          success: function (resp) { ... }
          type: "PUT"
          url: "event" // event is a folder with index.php
          validate: true
        }
    }
    
    Backbone.$.ajax.apply(Backbone.$, arguments);
    

    以下是浏览器提出的请求

    Request Method:PUT
    Status Code:301 Moved Permanently
    Request Headersview parsed
        PUT /maa/event HTTP/1.1
        Host: localhost
        Connection: keep-alive
        Content-Length: 123
        Cache-Control: no-cache
        Pragma: no-cache
        Origin: http://localhost
        X-Requested-With: XMLHttpRequest
        Content-Type: application/json
        Accept: application/json, text/javascript, */*; q=0.01
        User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36
        Referer: http://localhost/maa/
        Accept-Encoding: gzip,deflate,sdch
        Accept-Language: en-US,en;q=0.8,fr;q=0.6,fr-FR;q=0.4
    Request Payloadview parsed
        {"id":0,"dat":"10-03-2014","title":"Acton Vale","current":false,"enrole":[],"result":"","starts":{"m":{},"f":{}},"sex":"m"}
    

    除了生成301错误的看跌期权之外,其他所有工作都

0 个答案:

没有答案