Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Codeigniter 无法使用代码点火器、REST、Lighttpd url重写和Backbone.js接收PUT数据_Codeigniter_Rest_Backbone.js_Lighttpd - Fatal编程技术网

Codeigniter 无法使用代码点火器、REST、Lighttpd url重写和Backbone.js接收PUT数据

Codeigniter 无法使用代码点火器、REST、Lighttpd url重写和Backbone.js接收PUT数据,codeigniter,rest,backbone.js,lighttpd,Codeigniter,Rest,Backbone.js,Lighttpd,我将CodeIgniter与REST API和Backbone.js一起使用。Web服务器是lighttpd。我还更改了lighttpd.conf,以便重写URL以从URL中删除index.php,如下所示:- url.rewrite-once = ( "/(.*)\.(.*)" => "$0", "/(css|files|img|js|stats)/" => "$0", "^/([^.]+)$" => "/index.php/$1" ) 来自js的调用到达Codeig

我将CodeIgniter与REST API和Backbone.js一起使用。Web服务器是lighttpd。我还更改了lighttpd.conf,以便重写URL以从URL中删除index.php,如下所示:-

url.rewrite-once = (
 "/(.*)\.(.*)" => "$0",
 "/(css|files|img|js|stats)/" => "$0",
 "^/([^.]+)$" => "/index.php/$1"
)
来自js的调用到达Codeigniter Put函数,但$this->Put()的值为空。请帮助我跟踪PUT数据值为空的原因

注意:在我不重写URL的情况下,这可以很好地工作。这也适用于ApacheWeb服务器

在调试REST\u Controller.php文件时,在函数“protected function\u parse\u put()”中,我发现文件的内容php://input“它也是空的

以下是在进行PUT调用时从Chrome Web inspector获取的请求头和负载:-

**Request Headers**
PUT http://10.82.0.160/cav_settings/api/2 HTTP/1.1
Pragma: no-cache
Origin: http://10.82.0.160
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.56 Safari/537.17
Content-Type: application/json
Accept: application/json, text/javascript, */*; q=0.01
Referer: http://10.82.0.160/settings/2
X-Requested-With: XMLHttpRequest
**Request Payload**
{"aggregation":{"enabled":"false","mode":""},"dns":{"auto":"false","servers":["10.0.0.5","10.20.0.20"]},"id":"2","dhcp":"false","ip":"10.82.0.160","netmask":"255.255.255.0","default_gw":"","mtu":"1500"}

您可以使用Backbone.emulateJSON=true

这是回答您的疑问的最佳答案:)