【发布时间】: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