我在PHP中使用Fat Free Framework編寫了一個REST-ful API,並使用backbone.js進行調用。當我嘗試保存一個新訂單模型時,我的應用程序發出一個PUT請求,並且服務器吐出一個406錯誤。PUT請求返回來自Backbone.js的406(不可接受)返回到我的REST-ful PHP頁面
Request Method:PUT
Status Code:406 Not Acceptable
Request Headers
Accept:application/json, text/javascript, */*; q=0.01
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:174
Content-Type:application/json
Cookie:__utma=239804689.76636928.1286699220.1305666110.1325104376.94; __utmz=239804689.1325104376.94.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); PHPSESSID=935d2632fd0d12a1a0df4cb0f392eb5e
X-Requested-With:XMLHttpRequest
Request Payload
{"id":0,"customerId":0,"lastPage":"items","priceConfig":null,"items":null,"saveStatus":0,"savedAt":1326588395899,"name":null}
Response Headers
Connection:Keep-Alive
Content-Length:460
Content-Type:text/html; charset=iso-8859-1
Date:Sun, 15 Jan 2012 00:46:37 GMT
Keep-Alive:timeout=5, max=98
Server:Apache
我的.htaccess文件看起來是這樣的:
# Enable rewrite engine and route requests to framework
RewriteEngine On
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L,QSA]
# Disable ETags
<IfModule mod_headers.c>
Header Unset ETag
FileETag none
</IfModule>
# Default expires header if none specified (stay in browser cache for 7 days)
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault A604800
</IfModule>
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
我的網站應用程序工作正常,我的本地服務器上,只有做到這一點我的Web服務器上。任何想法出了什麼問題?
您是否在某處添加了['Script'](http://httpd.apache.org/docs/current/mod/mod_actions.html#script)指令來告訴Apache如何處理PUT請求? [見此](http://php.net/manual/en/features.file-upload.put-method.php)。 – DaveRandom 2012-01-15 01:06:41
添加「腳本PUT(任何目錄/文件)」給我一個500內部服務器錯誤 – 2012-01-15 02:56:04
在無脂框架(所有路由通過index.php完成)我使用下列路由PUT請求/訂單:F3 :: route( 'PUT/orders',dostuff());也許這是困惑的是,index.php正在調用PUT本身?我不明白Apache如何處理路由選擇。 – 2012-01-15 03:00:01