【问题标题】:Magento 1.7 REST API nginx rewrite rule. api.php no executedMagento 1.7 REST API nginx 重写规则。 api.php 没有执行
【发布时间】:2013-06-11 10:10:46
【问题描述】:

全部 如果我打开链接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;
  }

【问题讨论】:

    标签: api magento rest nginx rewrite


    【解决方案1】:

    我也看到了那个帖子,得到了同样的结果。
    我将规则从 break 更改为 last,现在似乎可以正常工作了:

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

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

    【讨论】:

      【解决方案2】:

      你应该在你的 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;
          }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-07-05
        • 1970-01-01
        • 2010-11-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-02-15
        相关资源
        最近更新 更多