Php magento重定向未更改为301
嗨,有人知道为什么这不是用301重定向吗?它一直返回302Php magento重定向未更改为301,php,magento,http-status-code-301,http-status-code-302,Php,Magento,Http Status Code 301,Http Status Code 302,嗨,有人知道为什么这不是用301重定向吗?它一直返回302 Mage::app()->getFrontController()->getResponse() ->setRedirect($newUrl,301) ->sendResponse(); 我甚至试图将其从抽象文件更改为仅用于测试 public function setRedirect($url, $code = 301) { $
Mage::app()->getFrontController()->getResponse()
->setRedirect($newUrl,301)
->sendResponse();
我甚至试图将其从抽象文件更改为仅用于测试
public function setRedirect($url, $code = 301)
{
$this->canSendHeaders(true);
$this->setHeader('Location', $url, true)
->setHttpResponseCode($code);
return $this;
}
我分析了Zend_Controller_Response_Abstract中的sendHeaders函数,在我的例子中,我试图从404页面重定向,因此标题更改了更多次,这让Magento感到困惑 在设置重定向之前清除标题是我的解决方案
Mage::app()->getResponse()->clearHeaders()->setRedirect($url, 301)->sendResponse();