Welcome Guest, Not a member yet? Register   Sign In
redirect() throwing a blank page, while header() works

Does anybody have a clue why would header() function work, while CI's redirect() is throwing a blank page. I have observerd it across various controllers. I even tested this right in my main controller, at the very beginning of the code.
Checked logs and error reporting with no result. I am almost 100% sure that nothing is showing up before the headers...

This is my main controller
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

define('HOST1', $_SERVER['HTTP_HOST']);
define('LOGO', 'http://img1.domain.com/logo/logo_v1_bg.gif');

class  MY_Controller extends Controller{

    function __construct(){
    function setup_assets(){

        if(!isset($this->data['url_array'])) $this->data['url_array'] = $this->uri->uri_to_assoc(2);
        //redirect for deleted categories
        $this->data['controller'] = $this->uri->segment(1);
        if( isset($this->data['url_array']['catid']) && isset($redirect_cat_array[$this->data['url_array']['catid']]) ){
            $redirect_link = str_replace('catid/'.$this->data['url_array']['catid'],'catid/'.$redirect_cat_array[$this->data['url_array']['catid']],$_SERVER['REQUEST_URI']);

NOtice above I comented out the redirect() function, because if I enable it and remove header function - I will get a blank page.

[eluser]Phil Sturgeon[/eluser]
Are there any errors showing up? Check your CodeIgniter logs to see if anything nuts is happening.

Where are you loading url_helper?

No errors show up, CI logs are empty (yeah - I try to keep on top of all the little issues and errors, so the logs usually are clean)
URL helper is loaded with autoload
What I can't get my head around is WHY is header() working and not redirect()? Are they not same behavior?
Is there a way to trace whats happeneing:

By the way, I did PAGE SOURCE for the blank page and this is what I see:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&lt;META http-equiv=Content-Type content="text/html; charset=utf-8"&gt;
&lt;META content=CMVRDPEJHO name=SKYPE_FRAMEID&gt;&lt;/HEAD>

what do you get if you echo out

Unfortunatly redirect() does not work even if the link is hardcoded, such as:

Thanks for the suggestion :-S


I encountered the same problem. After deactivating xdebug, everything was working again. (well, I admid my xdebug installation is php_xdebug-2.1.0beta1-5.3-vc9.dll)


what type of server are you using (linux, windows, mac, etc)?

have you tried setting the second optional parameter?

redirect($redirect_link, 'refresh'); // if using Windows, the 'refresh' is needed

also, I see you are setting the header to a 301 redirect. Why not set the redirect to the same thing?

redirect($redirect_link, 'refresh', 301);
redirect($redirect_link, 'location', 301); //may be faster, but don't use on a Windows server

[quote author="Phil Sturgeon" date="1258038024"]Where are you loading url_helper?[/quote]

That did it for me.
I was starting a new project and completely forgot to autoload this helper !

Theme © iAndrew 2016 - Forum software by © MyBB