即使在 NGINX 上发布到 php 文件时也不允许使用方法 (405)

发布于 2024-12-20 03:19:26 字数 589 浏览 0 评论 0原文

我一直在谷歌搜索,我所能找到的就是当您发布到 html 文件时可能会发生此错误。在我的设置中,我有一个重写规则,它基本上隐藏了 url 中的 index.php 文件,而且我很长一段时间认为它与此有关。 Get 工作正常,但由于某种原因 Get 无法与 OpenID 一起使用。

不允许的方法

URL /post.php 不允许 POST 请求

这是我的设置:

Debian squeeze / AMD64

nginx version: nginx/1.1.8

PHP 5.3.3-7+squeeze3 with Suhosin-Patch (cli) (built: Jun 28 2011 08:24:40) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH

I been googling, and all I can find is that this error may happen when you post to an html file. In my setup I have a rewrite rule, that basically hides the index.php file from the url, and I for the longest time thought it had something to do with that.
Get works fine, but Get for some reason doesn't work with OpenID.

Method Not Allowed

POST request is not allowed for the URL /post.php

Here is my setup:

Debian squeeze / AMD64

nginx version: nginx/1.1.8

PHP 5.3.3-7+squeeze3 with Suhosin-Patch (cli) (built: Jun 28 2011 08:24:40) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

怂人 2024-12-27 03:19:26

我刚刚自己解决了这个问题!

我安装了lighttpd,并且在lighttpd 中再次遇到同样的错误。
我正在查看所有错误的地方,因为错误 405 是网络服务器错误。

然而,我刚刚开始使用一个名为 fatfree F3 的新 php 框架,当您像这样使用 GET 时,该框架会生成错误:

F3::route('GET /autho/idreply', 'auth.php');

GET 意味着该框架只需要 GET 变量并将拒绝 POST 变量。

就是服务器错误 405!

因此,将其更改为,以下方法就达到了目的:

F3::route('POST /auth/oidreply', 'auth.php');  

您甚至可以使用此命令让框架接受两者或其中一个;

F3::route('GET|POST /auth/oidreply', 'auth.php');  

I just solved this problem my self!

I installed lighttpd, and got the same error again with lighttpd as well.
I was looking at all the wrong places because the error 405 is a webserver error.

However, I just started using a new php framework called fatfree F3, and the error is being generated by this framework when you use GET like so:

F3::route('GET /autho/idreply', 'auth.php');

The GET means that the framework is expecting only GET variables and will reject POST variables.

With a server error 405, that is!

So changing that to, following did the trick:

F3::route('POST /auth/oidreply', 'auth.php');  

And you can even let the framework accept both or either with this command;

F3::route('GET|POST /auth/oidreply', 'auth.php');  
和影子一齐双人舞 2024-12-27 03:19:26

我遇到了同样的错误。

我的问题是 POST 函数不接受第二个参数

function someForm($f3, $args){
    //some Process
}

I was getting the same error.

My problem was that the POST function did not accept a second argument

function someForm($f3, $args){
    //some Process
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文