-1

我有 nginx + php-fpm,当我尝试访问“/rest/proccess”时,我想要 $_SEVER['REQUEST_URI'] == '/process'。所以我刚刚为 nginx 创建了这样的配置:

location /rest/ {
    root   /var/www/php;

    rewrite ^/rest/(.*)$ /$1 break;

    fastcgi_pass  unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root/index.php;
    include        fastcgi_params;
}

但它不起作用,在 php 中我有 $_SEVER['REQUEST_URI'] == '/rest/process'。

我做错了什么?

谢谢

UPD:似乎重写规则只重写了 $document_uri,而不是 $request_uri,所以 $_SEVER['REQUEST_URI'] == '/rest/process' 和 $_SEVER['DOCUMENT_URI'] == '/process'

4

1 回答 1

0

我认为您需要将重写更改为:

rewrite ^/rest/(.+)$ $scheme://$host/$1;
于 2012-11-04T13:37:53.887 回答