Programmatically 301 Redirect – How to Implement

redirect

How can I programmatically perform a 301 redirect in Magento?

Best Answer

In Mage_Core_Controller_Response_Http::setRedirect(), the second option allows you supply the redirect code (defaults to 302), so

Mage::app()->getResponse()
    ->setRedirect($someUrl, 301)
    ->sendResponse();
Related Topic