Observer Strategy for a Winning Redirect
header('Location: ' . $url);
exit;
pattern. When you use the Magento response object to perform a redirect, execution continues, and the redirect doesn’t happen until after the controller has finished dispatching. Even if you wanted to you couldn’t use an exit
//will not do what you think
$this->getResponse()->setRedirect($url);
exit; //exits before the post dispatch code has a chance to perform the redirect
One side effect of this is your redirect may be shoved out of the way by another redirect that comes later. In this Stack Overflow question, which is shorter than this mini-essay, I recommend using a controller_action_postdispatch
observer to perform your redirects.