User dashboard where customer can login and can see all his information about ordered product and other information. In dashboard navigation menu, I added one more tab to redirect to external url. In controller, i am using $this->__redirect($url); bt is showing the error as : "Cannot send headers; headers already sent"

I used a code in controller as :

    public function fooAction(){

$url = "http://example.com/bar/"; // this is external url 
// Mage::app()->getResponse()->setRedirect($url);


It might be very easy but as I don't know, how to debug this in magento.



It may be because of extra white spaces after php closing tag (?>) in the file. This error also shown because of following points -

1.Any HTML output, including the DOCTYPE declaration or any HTML tag, including the head of the page

2.Extra whitespace before the opening PHP tag of the page, or outside the PHP tags of an include file

3.Using print() or echo before calling header() or session_start()

4.Using virtual() to include files

5.Using the byte-order mark (BOM) at the beginning of a page
  • @MagikTejas... Thank your very much. I am redirecting to external url (not in magento installation) and its in magento so I don't have any clue where should I check for the this issue. In one installation I am using magento and I am redirecting to other folder where codigniter is installed. Once the customer hit the Tab which is dashboard which will goes to my controller and in controller I am redirecting to external url. I am sorry, if something wrong as I am new in programming. In native I am able to check but in magneto unable to this information. ' – MagentoBoy Sep 16 '13 at 6:48
  • I have used ob_start() on the top of the controller.. and its working fine for me :).. thank you very much :) – MagentoBoy Sep 16 '13 at 11:10
  • @magicTejas.. may add you in fb or tweeter? – MagentoBoy Sep 16 '13 at 11:11

Try using below function


instead of


Now your function will look something like below

public function fooAction(){

$url = "http://example.com/bar/"; // this is external url 
// Mage::app()->getResponse()->setRedirect($url);

  • @anshu.. thank you very much... I have used $this->_redirectUrl($url); and I also used ob_start() function in controller on the top of the page ... and after trying this it is working fine ... thank you all :) – MagentoBoy Sep 16 '13 at 11:08

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.