NGINX 中的查询字符串

Query strings in NGINX

我在 nginx.
上的配置服务器有问题 我的配置:

server {
    listen                80;

    server_name           shop.md;
    index  index.php index.html index.htm;

    access_log            /var/log/nginx/test.dev.access.log;
    error_log             /var/log/nginx/test.dev.error.log;

    location / {
        root  /home/vagrant/Workspace/shop/web;
        try_files $uri $uri/ app_dev.php /app_dev.php$is_args$args;
    }

    location ~ .php$ {
        root  /home/vagrant/Workspace/shop/web;
        index  index.html index.htm index.php;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $request_filename;
        fastcgi_param APPLICATION_ENV development;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
    }

    sendfile off;
}

此配置允许这样的网址:

http://shop.md:8000/1/femei-pantofi
http://shop.md:8000/1/femei-pantofi?min_price=1&max_price=1000

为此URL:

http://shop.md:8000

我收到错误 403 Forbidden

我的 Symfony2 项目使用 @rewriteapp directive nginx。生成的配置看起来有点像这样:

# strip app.php/ prefix if it is present
rewrite ^/app\.php/?(.*)$ / permanent;

location / {
    index app.php;
    try_files $uri @rewriteapp;
}

location @rewriteapp {
    rewrite ^(.*)$ /app.php/ last;
}

# pass the PHP scripts to FastCGI server from upstream phpfcgi
location ~ ^/(app|app_dev|adminer)\.php(/|$) {
    fastcgi_pass phpfcgi-siyabonga;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    include fastcgi_params;
    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param  HTTPS off;

    fastcgi_buffer_size 128k;
    fastcgi_buffers 4 256k;
    fastcgi_busy_buffers_size 256k;
}

这对我来说效果很好,取自 official nginx wiki page about Symfony2 with some additional changes. Also you should check the official Symfony2 docs. They have an example of a correct nginx configuration