Prestashop Webservice api url 重定向 [英] Prestashop Webservice api url redirection
问题描述
我正在尝试运行一个简单的网络服务来获取客户的 XML 列表,但是在获取 http 时://www.myshopurl.com/api/customers,PS 重定向到首页.
I'm trying to run a simple webservice to get a XML list of customers but, when getting http://www.myshopurl.com/api/customers, PS redirects to frontpage.
Mod_rewrite 在 apache 中开启(用 phpinfo 函数检查).认为 .htaccess 格式良好:
Mod_rewrite is on in apache (checked with phpinfo function). Think that .htaccess is well formed:
# ~~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.添加了新的网络服务并激活.
Im using Prestashop 1.6.0.14 and PHP Version 5.5.9-1ubuntu4.19. Added new webservice and activated.
以其他方式,我已将 000-default.conf apache 文件配置为:
In other way, I've configured my 000-default.conf apache file as this:
<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>
不知道您是否需要更多数据.感谢您抽出宝贵时间.
Don't know if you need more data. Thanks for your time.
推荐答案
好的,抱歉,伙计们,发现问题了.
Ok, sorry dudes, problem found.
服务器有同时运行的 NGinx 和 Apache.我虽然那个 apache 正在与 prestashop 的前面一起工作,但我错了.Nginx 是.
Server has a NGinx and Apache working at same time. I though that apache was working with prestashop's front but I was wrong. Nginx is.
Nginx 配置有一个规则,将所有 URL 重定向到 index.php.我在/api/* 中添加了新规则并解决了问题.
Nginx config had a rule that redirected all URL's to index.php. I've added new rule to /api/* and problem solved.
这篇关于Prestashop Webservice api url 重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!