Nginx+PHP-FPM 的怎么配置让它支持 RESTFul?

2016-05-12 11:08:24 +08:00
 haython

这种方式的配置可以使用 delete , put 等方法了,但是只能访问 http://rest.website.com/,其它路径不能访问

server {
  listen        80;
  server_name   rest.website.com;
  root          /website/public/;
  index         index.php;
  location / {
    include         fastcgi.conf;
    fastcgi_index   index.php;
    fastcgi_pass    127.0.0.1:9000;
  }
}

这种方式可以访问其它路径,但是不能用 delete , put 等方法,只要 nginx 认为是访问的文件,就不能使用 delete , put 等方法

server
{
        listen          80;
        server_name     rest.website.com ;
        index           index.php;
        root            /website/public/;
        location / {
            try_files $uri $uri/ /index.php$is_args$args;
        }
        location ~ .*\.php?$ {
            try_files $uri =404;
            fastcgi_index index.php;
            include fastcgi.conf;
            fastcgi_pass 127.0.0.1:9000;
        }
}

搜索了一大圈没找到要怎么配置

6074 次点击
所在节点    PHP
2 条回复
zhengkai
2016-05-12 11:19:10 +08:00
无责任建议尝试一下 error_page 403 404 /index.php;

写在 location {} 之外
ryd994
2016-05-12 22:56:32 +08:00
全部由 index.php 处理么?
加上
fastcgi_param SCRIPT_FILENAME /full/path/to/index.php;
或者直接全局 rewrite 到 /index.php

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/278121

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX