【问题标题】:Prestashop Webservice api url redirectionPrestashop Webservice api url 重定向
【发布时间】:2017-04-18 14:56:03
【问题描述】:

我正在尝试运行一个简单的 Web 服务来获取客户的 XML 列表,但是在获取 http://www.myshopurl.com/api/customers 时,PS 会重定向到首页。

Mod_rewrite 在 apache 中开启(通过 phpinfo 函数检查)。认为 .htaccess 格式正确:

# ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again
# .htaccess automaticaly generated by PrestaShop e-commerce open-source solution
# http://www.prestashop.com - http://www.prestashop.com/forums

<IfModule mod_rewrite.c>
    <IfModule mod_env.c>
        SetEnv HTTP_MOD_REWRITE On
    </IfModule>
RewriteEngine on
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 

#Domain: www.mydomain.com
RewriteRule . - [E=REWRITEBASE:/]
RewriteRule ^api$ api/ [L]

RewriteRule ^api/(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]

# AlphaImageLoader for IE and fancybox
RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L]
</IfModule>

AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType font/otf .otf
AddType application/x-font-woff .woff
<IfModule mod_headers.c>
    <FilesMatch "\.(ttf|ttc|otf|eot|woff|svg)$">
        Header add Access-Control-Allow-Origin "*"
    </FilesMatch>
</IfModule>

#If rewrite mod isn't enabled
ErrorDocument 404 /index.php?controller=404

# ~~end~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again

我使用 Prestashop 1.6.0.14 和 PHP 版本 5.5.9-1ubuntu4.19。添加新的网络服务并激活。

另外,我将我的 000-default.conf apache 文件配置为:

<VirtualHost 127.0.0.1:8080>

    DocumentRoot /opt/prestashop_folder/
    ServerName mydomain.com
    ServerAlias www.mydomain.com
    <Directory /opt/prestashop_folder>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Require all granted
    </Directory>
</VirtualHost>

不知道您是否需要更多数据。感谢您的宝贵时间。

【问题讨论】:

    标签: php apache .htaccess web-services prestashop-1.6


    【解决方案1】:

    好的,抱歉伙计们,问题找到了。

    服务器有一个 NGinx 和 Apache 同时工作。我虽然那个 apache 正在使用 prestashop 的前端,但我错了。 Nginx 是。

    Nginx 配置有一条规则将所有 URL 重定向到 index.php。我已向 /api/* 添加了新规则,问题已解决。

    【讨论】:

      【解决方案2】:

      PrestaShop Nginx 配置

      rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;

      https://gist.github.com/julienbourdeau/79961e9caa4263e9e34d2d056948d335

      【讨论】:

      • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
      猜你喜欢
      • 1970-01-01
      • 2019-02-14
      • 1970-01-01
      • 2016-01-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多