Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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]

share|improve this question
    
Have you found an answer? I am running into the same issue –  Rabbi Nov 26 '12 at 1:32

1 Answer 1

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.

share|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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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