Nginx + Symfony2从url中删除app.php

时间:2014-06-28 15:27:28

标签: symfony nginx

我已将rewrite ^/app\.php/?(.*)$ /$1 permanent;添加到我的配置文件中,但它会创建一个重定向循环。

有什么想法吗?我第一次使用nginx ......

此致

1 个答案:

答案 0 :(得分:0)

请尝试使用以下主机配置

server {
    listen       127.0.0.1:80;
    server_name  symfony2.dev;

    root   /Users/user/public_html/symfony/web/;
    index   app_prod.php;
    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    rewrite ^/app_prod\.php/?(.*)$ /$1 permanent;

    location / {
        root   /Users/user/public_html/symfony/web/;
        try_files $uri @rewriteapp;
    }

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

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ ^/(app)(_\w+)?\.php(/|$) {
        fastcgi_pass        127.0.0.1:9000;
        fastcgi_buffer_size 8k;
        fastcgi_buffers     256 16k;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        fastcgi_param       SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param       HTTPS              off;
        include         fastcgi_params;
    }

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