I am building a RESTFUL API and need to get Apache to accept PUT requests. Whenever I put to a URL, I am getting a 403 Forbidden error.

curl -X PUT api.example.com/api/foo

I have tried to add the following to my Virtual Directory (To no avail):


<Limit GET POST PUT DELETE HEAD OPTIONS>
    Order allow,deny
    Allow from all
</Limit>
<LimitExcept GET POST PUT DELETE HEAD OPTIONS>
    Order deny,allow
    Deny from all
</LimitExcept>

What other config settings might be causing this?

EDIT

I am re-writing my URL's, all get re-written to index.php as follows:


RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !\.
RewriteRule ^(.*)$ /api/index.php/$1 [L,QSA]

link|improve this question

25% accept rate
feedback

1 Answer

Edit:

Add this to your Apache conf:

 Script PUT /api/index.php

This assumes your actual handler script is called index.php and it's located on /api.

link|improve this answer
I updated my post with the mod_rewrite info, if I make the PUT request directly to the PHP script it returns 403 as well. – mmattax May 31 '11 at 13:36
Sounds like Apache's allowing the request just fine, but the PHP is spitting out the 403. – Shane Madden May 31 '11 at 14:10
What @Shane said. Can you GET it? – Eduardo Ivanec May 31 '11 at 14:16
Yes, GET and POST work fine. Could it be PHP even though the error page being served is Apache's? – mmattax May 31 '11 at 14:17
I think I was wrong - try making the change in my edit. – Eduardo Ivanec May 31 '11 at 14:21
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.