简体   繁体   中英

Method not allowed (405) Must be one of: GET - Slim3 + Apache + AWS

I have been struggling with this for some time and don't know the what I am doing wrong.

I am using Slim3 (with LAMP) behind an Apache server. HTTP GET and POST works just fine. However, PUT and DELETE throws this weird error.

Method not allowed Method not allowed. Must be one of: GET

And this is the header on postman which says - Allow -> GET . What is setting this? Feel it is an Apache configuration, however, I don't know how to fix this. I am running my API on AWS (Linux).

在此处输入图片说明

Here is my .htaccess

RewriteEngine On

# Some hosts may require you to use the `RewriteBase` directive.
# If you need to use the `RewriteBase` directive, it should be the
# absolute physical path to the directory that contains this htaccess file.
#
# RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

Route to /api/v1/spark/warranty/3 must be declared with put() to be able to use PUT

$app->put('/api/v1/spark/warranty/3', function() {
   ....
});

and for DELETE, with delete()

$app->delete('/some/other/url/api', function() {
   ....
});

See Slim 3 Route documentation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM