2

Symfony2 をインストールした後、この URL にアクセスしようとしています:

http://test/symfony/web/app_dev.php/

しかし、末尾のスラッシュが原因で動作しません。404 が返されます。

これらは正常に動作します:

http://test/symfony/web/app_dev.php
http://test/symfony/web/app_dev.php?/

Apache では、/app_dev.php/something と /app_dev.php?/something は同じでした。Nginxでこれを機能させる方法について何か考えはありますか?

書き直しを追加しようとしましたが、運がありませんでした:

    location / {
            try_files $uri $uri/ @rewrite index.html;
    }

    location @rewrite {
            rewrite ^/(.*\.php)/(.*)$ $1?/$2;
    }
4

2 に答える 2

1

これは私が持っているもので、正常に動作します:

    location / {
            # Remove app.php from url, if somebody added it (doesn't remove if asked for /app.php on the root)
            rewrite ^/app\.php/(.*) /$1 permanent;

            try_files $uri $uri/ /app.php?$query_string;
    }

    location ~ \.php$ {
            try_files $uri = 404;
            # Below is for fastcgi:
            # fastcgi_pass    127.0.0.1:9000;
            # fastcgi_index   app.php;
            # include         /etc/nginx/fastcgi_params;
            # fastcgi_param   SCRIPT_FILENAME /mnt/www/live/current/web$fastcgi_script_name;
            # fastcgi_param   SERVER_PORT 80;
            # fastcgi_param   HTTPS off;
    }
于 2012-05-21T19:04:21.257 に答える
0

私はついに私のために働く答えに出くわしました:

    location ~ /directory/(.*\.php)(/.*)$ {
            set $script_filename $1;
            set $path_info $2;
            fastcgi_param  PATH_INFO        $2;
            alias /place/directory/$1;
            include fastcgi_params;

https://github.com/plack/Plack/issues/281

ドキュメントの関連するスニペットは次のとおりです。script_nameまたはpath_infoが正しくないことがわかっているため、nginxが提供するFCGIパラメーターを使用していないことに注意してください。

location / {
 set $script "";
 set $path_info $uri;
 fastcgi_pass unix:/tmp/fastcgi.sock;
 fastcgi_param  SCRIPT_NAME      $script;
 fastcgi_param  PATH_INFO        $path_info;
于 2012-11-01T19:28:05.547 に答える