Magento的类别重定向切断的URL的查询字符串字符串、重定向、类别、Magento

2023-09-02 01:01:35 作者:就让我忘记你的好

我们正在运行的Magento 1.4.2.0网上商店与谷歌分析。 大家都知道谷歌附加了一个名为添加gclid - 参数的URL查询字符串。

we are running a Magento 1.4.2.0 Webshop with google analytics. As we all know google attaches a querystring called the "gclid-Param" to the url.

客户点击以下链接: http://www.myshop.com /bathrooms/showersbaths.html?glicd=somevalue

类别浴室更名为内Magento的,所以Magento的自动创建从旧的类别名称重定向到新的名称浴室家具。

The category "bathrooms" was renamed inside magento, so magento automatically created a redirect from the old categoryname to the new name "bathroom furniture".

所以现在我们有这个问题,那Magento的切断与GLIC-参数时,它重写并重定向的URL查询字符串。

So now we have the problem, that magento cuts off the querystring with the glic-param when it rewrites and redirects the url.

有谁知道我们如何prevent本文或其中核心模块必须修改新的URL的大楼?

Does anybody know how to prevent this or in which core-Module we have to modify the building of the new url?

最好的问候 马库斯

推荐答案

在Magento的混乱里面的一些更深入的研究,我们找到了解决方案来解决我们的问题。

After some more deep research inside the chaos of magento we found the solution to solve our Problem.

在网址模型Mage_Core中存在一类rewrite.php。 我们创建了一个自定义模式,overwrited的rewrite.php。

In the Url-Model of the Mage_Core exists a class rewrite.php. We created a custom model and overwrited the rewrite.php.

在函数改写()中,我们增加了code以下的一段(标记为注释):

Inside of the function rewrite(), we added the following piece(marked as comments) of code:

//$url_params = false;
//if ($url_params = $_SERVER['QUERY_STRING'])
//$url_params = "?".$url_params;

if ($external === 'http:/' || $external === 'https:') 
{
    if ($isPermanentRedirectOption) 
    {
        header('HTTP/1.1 301 Moved Permanently');
    }

    header("Location: ".$this->getTargetPath() //.$url_params);
    exit;
} 
else 
{
    $targetUrl = $request->getBaseUrl(). '/' . $this->getTargetPath();
}
$isRedirectOption = $this->hasOption('R');
if ($isRedirectOption || $isPermanentRedirectOption)
{
    if (Mage::getStoreConfig('web/url/use_store') && $storeCode =    
    Mage::app()->getStore()->getCode()) 
    {
        $targetUrl = $request->getBaseUrl(). '/' . $storeCode . '/'  
        .$this->getTargetPath();
    }
    if ($isPermanentRedirectOption)
    {
         header('HTTP/1.1 301 Moved Permanently');
    }
    header('Location: '.$targetUrl //.$url_params);
    exit;
}

所以我希望我们的解决方案可以帮助其他人,谁是面临同样的问题。

So i hope our solution helps others, who are facing the same problem.

最好的问候 马库斯