Yii Redirect Is Not Working Correctly In Server

Hi there,

After login I’m trying to redirect the user based on their user role to their specified page. I tried redirect and header but both is not working for me in the server.

I tried,



header(‘Location: dashboard/profile’);

I’m getting this error

Cannot modify header information - headers already sent by (output started at /home/deheal/public_html/dev/index.php:2)

This all working perfectly in the local but not in the server please help me.

Thanks in advance.

You have to search for output to the user before the redirect.

If you cannot find anything (based on own experience), you have to look for blank lines at the end of included files. For example will this in the end of a file result in your error message (one blank line):


I don’t know how many hours I wasted before I realized that mistake :)