Magento category redirect cuts off the querystring of an url

后端 未结 3 662
暗喜
暗喜 2021-01-26 13:25

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.

The customer clicks t

3条回答
  •  天涯浪人
    2021-01-26 14:01

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

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

    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.

    Best regards Markus

提交回复
热议问题