【发布时间】:2018-01-11 17:40:04
【问题描述】:
我正在为 woocommerce 创建一个插件,该插件将 POST 发送到服务,然后响应应该重定向到另一个 url
$response = json_decode($result, true);
if ($response != null || $response != "") {
$woocommerce->cart->empty_cart();
// TODO Check when we use other cryptocurrency
// header("HTTP/1.1 304 Not Modified");
header('Location: ' . $response['data']['url']."?cryptoCurrency=BTC", true, 301);
exit();
}
此重定向在本地有效,但在生产中请求不会重定向。我收到一个通用错误syntaxerror: unexpected token < in Json at position 0 和一个以 OPTIONS 204 作为响应的响应,另一个是 301,另一个是 200(下面的图片链接)。
我想这与服务器有关,但我真的不知道会是什么。
编辑:结果有一个有效的 url。它只是不重定向。作为回应,我可以获取网址并通过浏览器访问
【问题讨论】:
-
可能是 $result 的 json 语法错误。请在线检查您的json
-
Khushboo,结果有这个url。它只是不重定向。作为回应,我可以获取网址并通过浏览器访问。
-
能否在您的问题中添加回复?
-
Khushboo,这是响应gist.github.com/Jonss/3fa656b07eaf655cfe4c103fb1400f97的var_dump
标签: php wordpress redirect woocommerce