Answers:
Magento依赖于$_SERVER['HTTP_REFERER']
重定向逻辑的值而没有任何限制;见Mage_Core_Controller_Varien_Action
:
/**
* Set referer url for redirect in responce
*
* @param string $defaultUrl
* @return Mage_Core_Controller_Varien_Action
*/
protected function _redirectReferer($defaultUrl=null)
{
$refererUrl = $this->_getRefererUrl();
if (empty($refererUrl)) {
$refererUrl = empty($defaultUrl) ? Mage::getBaseUrl() : $defaultUrl;
}
$this->getResponse()->setRedirect($refererUrl);
return $this;
}
/**
* Identify referer url via all accepted methods (HTTP_REFERER, regular or base64-encoded request param)
*
* @return string
*/
protected function _getRefererUrl()
{
$refererUrl = $this->getRequest()->getServer('HTTP_REFERER');
if ($url = $this->getRequest()->getParam(self::PARAM_NAME_REFERER_URL)) {
$refererUrl = $url;
}
if ($url = $this->getRequest()->getParam(self::PARAM_NAME_BASE64_URL)) {
$refererUrl = Mage::helper('core')->urlDecode($url);
}
if ($url = $this->getRequest()->getParam(self::PARAM_NAME_URL_ENCODED)) {
$refererUrl = Mage::helper('core')->urlDecode($url);
}
if (!$this->_isUrlInternal($refererUrl)) {
$refererUrl = Mage::app()->getStore()->getBaseUrl();
}
return $refererUrl;
}
如果您不满足于依赖$_SERVER['HTTP_REFERER']
,那么您唯一可以做的就是将最新访问的URL存储在session中,并为此值创建一个getter来处理有人直接导航到该站点的情况。