2014-02-07 98 views
5

我最近在Windows 7中安装了nginx 1.4.4和PHP 5.5.8。我运行nginx.exe和php-cgi.exe来运行服务器并运行。当我在URL中发送查询字符串时,如果我print_r($_GET)从查询字符串中具有值。但如果我print_r($_REQUEST)$_REQUEST只是空阵列。我在stackoverflow中关注了一些其他问题,我发现所有的问题都是检查request_order和variables_order。在php.ini 这是在php.ini我目前的配置request_order和variables_order选项:

; This directive determines which super global arrays are registered when PHP 
; starts up. G,P,C,E & S are abbreviations for the following respective super 
; globals: GET, POST, COOKIE, ENV and SERVER. There is a performance penalty 
; paid for the registration of these arrays and because ENV is not as commonly 
; used as the others, ENV is not recommended on productions servers. You 
; can still get access to the environment variables through getenv() should you 
; need to. 
; Default Value: "EGPCS" 
; Development Value: "GPCS" 
; Production Value: "GPCS"; 
; http://php.net/variables-order 
variables_order="GPCS" 

; This directive determines which super global data (G,P,C,E & S) should 
; be registered into the super global array REQUEST. If so, it also determines 
; the order in which that data is registered. The values for this directive are 
; specified in the same manner as the variables_order directive, EXCEPT one. 
; Leaving this value empty will cause PHP to use the value set in the 
; variables_order directive. It does not mean it will leave the super globals 
; array REQUEST empty. 
; Default Value: None 
; Development Value: "GP" 
; Production Value: "GP" 
; http://php.net/request-order 
request_order="GP" 

我也找到了答案关闭auto_globals_jit,但它不工作。 我有一个工作安装的xampp 1.8.3,它在Apache服务器上工作。但是当nginx使用xampp的PHP时,$_REQUEST也是空的。

一些文章告诉改变nginx配置在fastcgi_params中添加query_string。但是案件是$_SERVER['QUERY_STRING']是空的。但对于我的情况,$_SERVER['QUERY_STRING']包含价值。我仍然尝试,但它也不起作用。

还缺什么?谢谢。

EDIT

这是我的nginx的服务器配置(我用代码点火器,所以遵循http://wiki.nginx.org/Codeigniter用于配置:

server { 
    listen  80; 
    server_name local.dev.com; 
    root html/dev; 
    autoindex on; 
    index index.php; 

    location/{ 

     try_files $uri $uri/ /index.php; 

     location = /index.php { 

      fastcgi_pass 127.0.0.1:9000; 
      fastcgi_param QUERY_STRING  $query_string; 
      fastcgi_param SCRIPT_FILENAME D:/nginx/html/dev$fastcgi_script_name; 
      include  fastcgi_params; 
     } 
    } 

    location ~ \.php$ { 
     return 444; 
    } 
} 
+0

问题,您可以发布从nginx的plase你的'fastcgi_param'配置。 – Fleshgrinder

+0

@Fleshgrinder你的意思是fastcgi_param在nginx.conf中?我已经更新了该问题以包含配置。 –

回答

0

笨手动建立从$_SERVER['REQUEST_URI']$_GET,使用的协议REQUEST_URI时AUTO(参见$config['uri_protocol'])。

你应该修改的nginx的配置,替换行:

try_files $uri $uri/ /index.php; 

try_files $uri $uri/ /index.php$is_args$args; 

为了解决空$_REQUEST