Enable PUT and DELETE methods on Apache 2.4

2019-02-15 22:03发布

问题:

I'd like to enable on my Apache 2.4 under linux the PUT and DELETE methods. When clients try to invoke such methods I get a "405 Method Not Allowed" as answer.

On server side my PHP script handle such requests but it seems filtered by the server itself (that's makes the difference from the similar already answered question - Moreover other questions seems to refers to an old version of Apache).

Can I manage some configurations on .htaccess file or I have to modify the .conf files under /etc/apache2?

Thanks a lot.

回答1:

Try the following changes on your server:

Open "/etc/httpd/conf/httpd.conf" and look for the following blocks:

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

Then just add PUT and DELETE after PROPFIND. Then Restart httpd by "/sbin/service httpd restart" or service httpd restart.

Note: In some servers , mostly the ones with a control panel (DA,cPanel,..) you may change this file :/etc/httpd/conf/extra/httpd-directories.conf

I hope it solves your problem.



标签: apache lamp