What's fastcgi_param scope

Jakub Zalas jzalas at gmail.com
Thu Mar 24 02:34:38 MSK 2011


Hi,

I'm experiencing odd behavior of fastcgi_param.

Based on the URL I'd like to pass additional parameters to PHP.

For example:

location ~ "^/foo/bar$" {
  # this is not passed to fastcgi and not acesible via $_SERVER
  fastcgi_param _ROUTING__route foo;
  fastcgi_index app.php;
  rewrite ^(.*) /app.php last;
}

# standard PHP stuff
location ~ \.php {
    set  $script     $uri;
    set  $path_info  "";
    if ($uri ~ "^(.+\.php)(/.*)") {
      set  $script     $1;
      set  $path_info  $2;
    }
    fastcgi_pass   127.0.0.1:9000;
    include /etc/nginx/fastcgi_params;
    fastcgi_param  SCRIPT_FILENAME  /var/www/$host/web$script;
    fastcgi_param  PATH_INFO        $path_info;
    fastcgi_param  SCRIPT_NAME $script;
}

I also tried nesting location but the result is the same.
fastcgi_param defined in nested location block is not passed to PHP.

Could anyone explain me why it works this way?




More information about the nginx mailing list