![](/img/trans.png)
[英]Slim Framework Method not allowed. Must be one of: POST (405)
[英]Method not allowed (405) Must be one of: GET - Slim3 + Apache + AWS
我已经为此苦苦挣扎了一段时间,不知道我在做什么错。
我在Apache服务器后面使用Slim3(带有LAMP)。 HTTP GET
和POST
可以正常工作。 但是, PUT
和DELETE
会引发此奇怪的错误。
Method not allowed Method not allowed. Must be one of: GET
这是邮递员的header
,上面写着Allow -> GET
。 这是什么设置? 感觉这是一个Apache配置,但是,我不知道该如何解决。 我在AWS(Linux)上运行我的API。
这是我的.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]
必须使用put()
声明到/api/v1/spark/warranty/3
路由,才能使用PUT
$app->put('/api/v1/spark/warranty/3', function() {
....
});
对于DELETE,使用delete()
$app->delete('/some/other/url/api', function() {
....
});
请参阅Slim 3 Route文档 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.