0

I configured my NGINX for Zend in the following way (PHP 5.3 with fpm):

server {
root /home/page/public/;
index index.php index.html index.htm;

server_name localhost;

location / {
    try_files $uri $uri/ /index.php;
}

location ~ \.php$ {
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include        fastcgi_params;
}

location ~ /\.ht {
    deny all;
}
}

Now i want to process additional get params like: http://web.site/index?par=1

WIth my local dev system (Apache) it works fine but not under NGINX which did'T deliver the get params.

Anny suggestions?

Edit:

Now i use the following config which seems to work but i'm not happy with it since everybody suggests "use try_files whenever possible".

location / {
    if (!-e $request_filename) {
        rewrite  /(.*)$  /index.php?q=$1  last;
        break;
    }
}
4
  • How actually do you try to get it? Commented Sep 8, 2011 at 12:29
  • To test it with print_r($_GET) but later with $values = $this->getRequest()->getQuery(); Commented Sep 8, 2011 at 12:30
  • The Problem isn't the script the problem is think is that the script filename is index.php without the params, so php cant fill the $_GET array etc. Commented Sep 8, 2011 at 12:35
  • Try this try_files $uri $uri/ /index.php?q=$uri&$args; instead of if. Commented Sep 8, 2011 at 14:43

2 Answers 2

4

From Nginx docs ( http://wiki.nginx.org/HttpCoreModule#try_files):

If you need args preserved, you must do so explicitly:

location / {
   try_files $uri $uri/ /index.php?$args;
}
Sign up to request clarification or add additional context in comments.

Comments

-1

I use a rewrite module for this; try replacing your location / block with the following:

location / { 
    index  index.php index.html index.htm;
}   

if (!-e $request_filename) {
    rewrite ^.*$ /index.php last;
}

1 Comment

Yes, this works i already tried it and was about to edit my question but everybody says "use try_files whenever possible" so i'm still interested in a solution for it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.