Nginx/PHP/ZF2有类似于“quot;的扩展的路由问题;。php“;

Nginx/PHP/ZF2有类似于“quot;的扩展的路由问题;。php“;,php,nginx,zend-framework2,Php,Nginx,Zend Framework2,提前谢谢你的帮助 我在nginx中遇到了php+ZF2的问题 我们使用appache构建应用程序,现在我们希望在nginx中使用swift,我们面临如下问题 其中我的conf文件如下 server { root /usr/share/nginx/html/xmlhub/public; index index.php index.html index.htm; server_name nginx.xmlhub; location / { try

提前谢谢你的帮助

我在nginx中遇到了php+ZF2的问题

我们使用appache构建应用程序,现在我们希望在nginx中使用swift,我们面临如下问题

其中我的conf文件如下

server {

    root /usr/share/nginx/html/xmlhub/public;
    index index.php index.html index.htm;

    server_name nginx.xmlhub;

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

    location ~ \.php$ {
        include fastcgi_params;
        #fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/var/run/php5-fpm.sock;

      }

    location ~ .*\.(git|jpg|jpeg|png|bmp|swf|ico)?$ {
        expires 30d;
    }

    location ~ .*\.(js|css)?$ {
        expires 1h;
    }

    location ~ /\.ht {
        deny all;
    }
}
我的产品有很多扩展名为“.php”的url,所以我不能删除它

下面是我的ZF2代码快照

'common' => array(
                'type' => 'segment',
                'options' => array(
                     'route' => '/common/index.php[?action=:action][&id=:id][&page=:page][&country=:country][&img=:img]',

                    'constraints' => array(
                        'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                        'id' => '[a-zA-Z0-9]+',
                    ),
                    'defaults' => array(
                        'controller' => 'Common\Controller\Index',
                        'action' => 'login',
                        'page' => 1,
                    ),
                ),
                'may_terminate' => true,
                'child_routes' => array(
//                     'query' => array('type' => 'query'),
                ),
            ),
我在每个有php扩展的页面上都发现了错误


谢谢和问候

我已经尝试了你的配置,它在这里工作。你能确认文件/usr/share/nginx/html/xmlhub/public/common/index.php存在并且可读吗?是的,该文件存在于该位置,该代码在apache下工作,但我对nginx有问题,这些url具有php扩展名