0

When i click on add to compare link on product listing page my url is changing from

magento.com/personal-care/face.html?dir=asc&order=Normal

to

magento.com/personal-care/face.html?dir=asc&order=Normal

And the above link is breaking.

When I am making a small correction in the above url, by changing & to &. Then it is working fine for me.

I also tried RewriteRule ^(.*)&(.*)$ /$1&$2 [L,R=301] in .htaccess but no luck.

  • How does the button / link look like on the frontend. Is it an <a> tag with href attribute or is it using a JS function setLocation? If it's the latter I have the answer ready :) – Alex Dinca May 19 '17 at 13:42
  • it's in <a> tag, $this->getAddToCompareUrl($_product). – Pratik Dhamane May 20 '17 at 6:07
  • And the link is added in the href tag (href="<?php $this->getAddToCompareUrl($_product) ?>") or inside the onclick tag (onclick="setLocation(<?php $this->getAddToCompareUrl($_product) ?>)") – Alex Dinca May 21 '17 at 9:58
0

Please try this in .htaccess:

RewriteCond %{QUERY_STRING} ^(.*)&amp;(.*)$
RewriteRule ^(.*)$ /$1?%1&%2 [L,R=301]
  • I found solution thank you for your help. – Pratik Dhamane May 20 '17 at 13:22
  • @PratikDhamane your welcome! :) – Fayyaz Khattak May 22 '17 at 6:29
0

To overcome this problem i just rewrite app/code/core/Mage/Catalog/controllers/Product/CompareController.php

replaced

$this->_redirectReferer();

with

$refererUrl = $this->getRequest()->getServer('HTTP_REFERER');

$this->_redirectUrl($refererUrl);

in addAction() function.

It seems & is replace with &amp; because of the _getRefererUrl() function in

app/code/core/Mage/Core/Controller/Varien/Action.php

0

RewriteRule ^(.*)$ /$1?%1&%2 [L,R=301] is taking to index.php always. If I'm on the product page URL, I need to keep it, so for example:

www.domain.com/product.html?a1=v1&a2=v2

is taking me to

www.domain.com/index.php/?a1=v1&a2=v2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.