Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

405: Method Not Allowed #62

Closed
ycaihappy opened this issue Nov 14, 2017 · 6 comments
Closed

405: Method Not Allowed #62

ycaihappy opened this issue Nov 14, 2017 · 6 comments

Comments

@ycaihappy
Copy link

PHP Fatal error: Uncaught Exception: 405: Method Not Allowed

使用如下代码时,会报错,服务端使用nginx加了一个重定向wus/v1/ => public/index.php?version=v1

$client = Client::create('http://xxxx/wus/v1/', false);
$client->xxx();

不知道怎么处理?

@pavlelee
Copy link
Member

这应该和你用的框架有关吧,https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405

@lscgzwd
Copy link

lscgzwd commented Nov 14, 2017

405是nginx输出的,如果请求打到了一个静态文件上,并且是post请求就会这样,检查下nginx配置吧

@ycaihappy
Copy link
Author

楼上说的没错,但是如果hprose能支持GET请求(默认好像都是POST的?)静态资源这个问题是可以解决的。

这样的应用场景比较多,当nginx要实现伪静态时,大部分都是类似xx.html, xxx/xx/这种地址,不支持的话应付不了很多场景,apache也是类似。

@pavlelee
Copy link
Member

@ycaihappy 你没看明白,伪静态是可以可以的,但是这个明显是你的nginx配置错误,Client必须请求到一个Serve,请确认这个请求'http://xxxx/wus/v1/'能否到Serve

@lscgzwd
Copy link

lscgzwd commented Nov 15, 2017

贴出你的nginx配置一看就知道了。这个肯定是rewrite配置不对,导致请求没有到hprose上 或者说没有到php-fpm

@ycaihappy
Copy link
Author

@Liv1020 http://xxxx/wus/v1/ 是可以得到服务结果的。。
@lscgzwd nginx配置是正确的。。

问题已经解决。原因是使用lumen框架的时候路由注册的是GET,改成POST就可以了。谢谢大家关注。

POST /wus/v1/ HTTP/1.1" 405 没改lumen前
POST /wus/v1/ HTTP/1.1" 200 修改lumen后

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants