{"id":60841,"date":"2025-04-26T09:33:48","date_gmt":"2025-04-26T01:33:48","guid":{"rendered":"https:\/\/fwq.ai\/blog\/60841\/"},"modified":"2025-04-26T09:33:48","modified_gmt":"2025-04-26T01:33:48","slug":"zencart%e5%87%bd%e6%95%b0zen_redirect%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/60841\/","title":{"rendered":"ZenCart\u51fd\u6570zen_redirect\u4ecb\u7ecd"},"content":{"rendered":"<p> ZenCart\u51fd\u6570zen_redirect \u51fd\u6570\u7684\u529f\u80fd\u662f\u505a\u91cd\u5b9a\u5411\uff0c\u4e5f\u53ef\u4ee5\u8bf4\u662f\u9875\u9762\u8c03\u8f6c\u51fd\u6570&nbsp;\u3002\u8be5\u51fd\u6570\u5728includes\/functions\/functions_general.php \u6587\u4ef6\u4e2d\u5b9a\u4e49&nbsp;\u7b2c\u4e00\u4e2a\u53c2\u6570\u5c31\u662f\u8c03\u8f6c\u9875\u9762\u7684URL\u5730\u5740\uff0c\u5982\u679c\u662f\u7ad9\u5185\u5730\u5740\u7684\u8bdd\uff0c\u53ef\u4ee5\u4f7f\u7528zen_href_link()\u51fd\u6570\u6765\u751f\u6210\u5730\u5740\uff0c\u5982\u679c\u662f\u7ad9\u5916\u5730\u5740\u7684\u8bdd\uff0c\u53ef\u4ee5\u76f4\u63a5\u8f93\u5165URL\u5730\u5740\uff0c\u5305\u542bhttp:\/\/\u5f00\u5934\u7684\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5c31\u662f\u8fd4\u56de\u7684HTTP\u54cd\u5e94\u7801\uff0c\u4e00\u822c\u60c5\u51b5\u4e0b\u4e0d\u4f7f\u7528\u8be5\u53c2\u6570\uff0c\u8fd9\u4e2a\u53c2\u6570\u8ddfphp\u51fd\u6570void header ( string $string [, bool $replace = true [, int $http_response_code ]] )<br \/> \u7684\u6700\u540e\u4e00\u4e2a\u53c2\u6570\u4e00\u6837\uff0c\u5177\u4f53\u53ef\u4ee5\u53c2\u8003PHP\u51fd\u6570<br \/> zen_redirect\u51fd\u6570&nbsp;\u539f\u578b\u5982\u4e0b;<br \/> function&nbsp;zen_redirect($url, $httpResponseCode = \u201d) {<br \/> global $request_type;<br \/> \/\/ Are we loading an SSL page?<br \/> if ( (ENABLE_SSL == \u2018true\u2019) &amp;&amp; ($request_type == \u2018SSL\u2019) ) {<br \/> \/\/ yes, but a NONSSL url was supplied<br \/> if (substr($url, 0, strlen(HTTP_SERVER . DIR_WS_CATALOG)) == HTTP_SERVER . DIR_WS_CATALOG) {<br \/> \/\/ So, change it to SSL, based on site\u2019s configuration for SSL<br \/> $url = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG . substr($url, strlen(HTTP_SERVER . DIR_WS_CATALOG));<br \/> }<br \/> }<\/p>\n<p> \/\/ clean up URL before executing it<br \/> while (strstr($url, \u2018&amp;&amp;\u2019)) $url = str_replace(\u2018&amp;&amp;\u2019, \u2018&amp;\u2019, $url);<br \/> while (strstr($url, \u2018&amp;&amp;\u2019)) $url = str_replace(\u2018&amp;&amp;\u2019, \u2018&amp;\u2019, $url);<br \/> \/\/ header locates should not have the &amp; in the address it breaks things<br \/> while (strstr($url, \u2018&amp;\u2019)) $url = str_replace(\u2018&amp;\u2019, \u2018&amp;\u2019, $url);<\/p>\n<p> if ($httpResponseCode == \u201d) {<br \/> header(\u2018Location: \u2018 . $url);<br \/> session_write_close();<br \/> } else {<br \/> header(\u2018Location: \u2018 . $url, TRUE, (int)$httpResponseCode);<br \/> session_write_close();<br \/> }<\/p>\n<p> exit();<br \/> }<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ZenCart\u51fd\u6570zen_redirect \u51fd\u6570\u7684\u529f\u80fd\u662f\u505a\u91cd\u5b9a\u5411\uff0c\u4e5f\u53ef\u4ee5\u8bf4\u662f\u9875\u9762\u8c03\u8f6c\u51fd\u6570&nbsp;\u3002\u8be5\u51fd\u6570\u5728includes\/functions\/functions_general.php \u6587\u4ef6\u4e2d\u5b9a\u4e49&nbsp;\u7b2c\u4e00\u4e2a\u53c2\u6570\u5c31\u662f\u8c03\u8f6c\u9875\u9762\u7684URL\u5730\u5740\uff0c\u5982\u679c\u662f\u7ad9\u5185\u5730\u5740\u7684\u8bdd\uff0c\u53ef\u4ee5\u4f7f\u7528zen_href_link()\u51fd\u6570\u6765\u751f\u6210\u5730\u5740\uff0c\u5982\u679c\u662f\u7ad9\u5916\u5730\u5740\u7684\u8bdd\uff0c\u53ef\u4ee5\u76f4\u63a5\u8f93\u5165URL\u5730\u5740\uff0c\u5305\u542bhttp:\/\/\u5f00\u5934\u7684\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5c31\u662f\u8fd4\u56de\u7684HTTP\u54cd\u5e94\u7801\uff0c\u4e00\u822c\u60c5\u51b5\u4e0b\u4e0d\u4f7f\u7528\u8be5\u53c2\u6570\uff0c\u8fd9\u4e2a\u53c2\u6570\u8ddfphp\u51fd\u6570void header ( string $string [, bool $replace = true [, int $http_response_code ]] ) \u7684\u6700\u540e\u4e00\u4e2a\u53c2\u6570\u4e00\u6837\uff0c\u5177\u4f53\u53ef\u4ee5\u53c2\u8003PHP\u51fd\u6570 zen_redirect\u51fd\u6570&nbsp;\u539f\u578b\u5982\u4e0b; function&nbsp;zen_redirect($url, $httpResponseCode = \u201d) { global $request_type; \/\/ Are we loading an SSL page? if ( (ENABLE_SSL == \u2018true\u2019) &amp;&amp; ($request_type == \u2018SSL\u2019) ) { \/\/ yes, but a NONSSL url was supplied if (substr($url, 0, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-60841","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/60841","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=60841"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/60841\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=60841"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=60841"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=60841"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}