Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

codeigniter redirect not working

For some reason I can't spot, redirect in codeigniter is not working. I'm getting the white screen of death.

I set up a "test" controller:

class Test extends Controller {
    function Test() {
        parent::Controller();
        $this->load->helper('url');
    }

    function index() {
         redirect('home','refresh');

    }
}

(I've tried the location and refresh parameters, with no help).

Here's my .htaccess file:

DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

I've used all this before with good results. Anything else I can check?

Thanks.

John

like image 614
John Rand Avatar asked Apr 17 '11 10:04

John Rand


2 Answers

As it turned out, setting the log threshold to 4 was the answer to figuring this out. I was able to determine that I was outputting some space, which prevented the redirect from working. Looking in the logs revealed this.

Thanks everyone for your help, and thanks Madmartigan for suggesting the log setting.

like image 193
John Rand Avatar answered Oct 20 '22 13:10

John Rand


Try adding a ? at the end of index.php in your last rewrite rule as such:

RewriteRule ^(.*)$ ./index.php?/$1 [L,QSA]

If that doesn't work, try changing your $config['uri_protocol'] (if it's set to AUTO) to:

$config['uri_protocol'] = 'REQUEST_URI';

like image 28
Fuseblown Avatar answered Oct 20 '22 12:10

Fuseblown