Am using $this->_redirectReferer(); to redirect back to category page.
when i use some params, my url is like
then the redirected url is like
my url is encoded. all the & is changed to {&amp};
how can i avoid this.

1 Answer 1


The method Mage_Core_Controller_Varien_Action::_redirectReferer calls _getRefererUrl from the same class that contains this line:

$refererUrl = Mage::helper('core')->escapeUrl($refererUrl);

The escape url is basically htmlspecialchars().

You shouldn't change the _getRefererUrl method because it's risky, but you can write your own method similar with the _redirectReferer where you undo the htmlspecial chars and use that method:

Something like this:

protected function _redirectRefererNoSpecialChars($defaultUrl=null)

    $refererUrl = $this->_getRefererUrl();
    $refererUrl = htmlspecialchars_decode($str, ENT_NOQUOTES);//this needs to be added
    if (empty($refererUrl)) {
        $refererUrl = empty($defaultUrl) ? Mage::getBaseUrl() : $defaultUrl;

    return $this;
  • Mind that since, you probably want to use these updated flags: ENT_COMPAT | ENT_HTML5 | ENT_HTML401
    – Simon
    Sep 11, 2020 at 11:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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