繁体   English   中英

Magento 1.7 REST API nginx重写规则。 api.php没有执行

[英]Magento 1.7 REST API nginx rewrite rule. api.php no executed

如果我打开链接http://example.com/api/rest/products ,它只是下载了api.php,而不是脚本被执行。

它能是什么?

magento网站有我的nginx规则

location /api {
  rewrite ^/api/rest /api.php?type=rest break;
}
location / {
    index index.html index.php;
    try_files $uri $uri/ @handler;
    expires 30d;
}

location ~ (/(app/|includes/|lib/|/pkginfo/|var/|report/config.xml)|/\.svn/|/.hta.+) {
             deny all;
}

  location ^~ /(app|includes|lib|media/downloadable|pkginfo|report/config.xml|var)/ { internal; }
  location /var/export/ { internal; }
  location /. { return 404; }
  location @handler { rewrite / /index.php; }
  location ~* .php/ { rewrite ^(.*.php)/ $1 last; }
  location ~* .php$ {
    if (!-e $request_filename) { rewrite / /index.php last; }
    expires off;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param MAGE_RUN_CODE default;
    fastcgi_param MAGE_RUN_TYPE store;
    include fastcgi_params;
  }

我也看到了这个帖子,并得到了同样的东西。
我把规则从break改为last ,事情似乎现在有效:

location /api {
  rewrite ^/api/rest /api.php?type=rest last;
}

我相信它的工作方式是这样的,因为last重新扫描重写并可以执行你的'.php'位置指令,其中break只考虑当前的位置块(/ api)。 资料来源: http//wiki.nginx.org/HttpRewriteModule#rewrite

你应该在你的nginx配置中写这个:

   location /api 
    {
    rewrite ^/api/rest /api.php?type=rest last;
    rewrite ^/api/v2_soap /api.php?type=v2_soap last;
    rewrite ^/api/soap /api.php?type=soap last;
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM