简体   繁体   English

不允许使用方法(405)必须为以下之一:GET-Slim3 + Apache + AWS

[英]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. 我在Apache服务器后面使用Slim3(带有LAMP)。 HTTP GET and POST works just fine. HTTP GETPOST可以正常工作。 However, PUT and DELETE throws this weird error. 但是, PUTDELETE会引发此奇怪的错误。

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

And this is the header on postman which says - Allow -> GET . 这是邮递员的header ,上面写着Allow -> GET What is setting this? 这是什么设置? Feel it is an Apache configuration, however, I don't know how to fix this. 感觉这是一个Apache配置,但是,我不知道该如何解决。 I am running my API on AWS (Linux). 我在AWS(Linux)上运行我的API。

在此处输入图片说明

Here is my .htaccess 这是我的.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 必须使用put()声明到/api/v1/spark/warranty/3路由,才能使用PUT

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

and for DELETE, with delete() 对于DELETE,使用delete()

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

See Slim 3 Route documentation . 请参阅Slim 3 Route文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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