Search code examples
phpnginxfastcgi

Nginx passing parameters to a PHP file


I'm trying to pass all the requests that hits a specific location, to a PHP file with the request URL via Nginx config file, I've almost done this but I cannot pass the URL to the PHP file.

I've tried var_dump($_REQUEST); var_dump($_ENV); var_dump($argv); but returns NULL or emtpy array results.

location /p/ {

     try_files $uri $uri/ @php;         
}

location @php {
        fastcgi_pass   unix:/var/run/php5-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /var/process/internal/t.php; # this script catches all requests
        fastcgi_param  QUERY_STRING $uri;
        include fastcgi_params;
}

Solution

  • Try to move the include fastcgi_params; higher, above the fastcgi_params