【问题标题】:Rewrite request_uri fail重写 request_uri 失败
【发布时间】:2012-11-05 00:28:42
【问题描述】:

我有 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'

【问题讨论】:

标签: nginx php


【解决方案1】:

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

rewrite ^/rest/(.+)$ $scheme://$host/$1;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-16
    • 2020-12-13
    • 2020-09-29
    • 1970-01-01
    • 1970-01-01
    • 2010-12-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多