CodeIgniter Forums
Redirect() not working - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Redirect() not working (/showthread.php?tid=11222)

Pages: 1 2


Redirect() not working - El Forum - 08-30-2008

[eluser]ywftdg[/eluser]
In my controller, I am trying to fwd people somewhere when they hit the index, I have used this in the past with no problems.

Code:
function index()
    {
        
        redirect('projects');
        
    }

But now on this project, I am getting an error when I load the site:

A PHP Error was encountered
Severity: Notice

Message: Undefined offset: 0
Filename: libraries/Router.php
Line Number: 190
A PHP Error was encountered
Severity: Notice

Message: Undefined offset: 0
Filename: libraries/Router.php
Line Number: 196
A PHP Error was encountered
Severity: Notice

Message: Undefined offset: 0
Filename: libraries/Router.php
Line Number: 199
A PHP Error was encountered
Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /nfs/c01/h02/mnt/13322/domains/mydomain.com/system/libraries/Exceptions.php:164)
Filename: helpers/url_helper.php
Line Number: 485



Any ideas?


Redirect() not working - El Forum - 08-30-2008

[eluser]Randy Casburn[/eluser]
Did you include the URL helper?


Redirect() not working - El Forum - 08-30-2008

[eluser]ehicks727[/eluser]
The default redirect is a 302. If you want Google to like your site, better change that to a 301. Use the example from the user's guide

redirect('/article/13', 'location', 301);


Redirect() not working - El Forum - 08-31-2008

[eluser]Bramme[/eluser]
Did you echo anything before you used the redirect?


Redirect() not working - El Forum - 08-31-2008

[eluser]ywftdg[/eluser]
yes i loaded url helper, no echo, all i have is function above. maybe i need to try something different with my htaccess?


Redirect() not working - El Forum - 08-31-2008

[eluser]Bramme[/eluser]
No, the headers allready sent error is a sign that you're outputting something. This could even be whitespace.

Generally, it's good practice to remove the ending php ?> tag in pure php files. Also, make sure you've got no tabs, enters or spaces before your opening <?php tag.


Redirect() not working - El Forum - 08-31-2008

[eluser]ywftdg[/eluser]
my redirect is in my controller, so how can I be sending anything?


Redirect() not working - El Forum - 08-31-2008

[eluser]ywftdg[/eluser]
It was my htaccess:

My original was:
RewriteEngine on
RewriteCond $1 !^(index\.php|ee.php|ee|assets|include|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

Then I changed the last line to:
RewriteRule ^(.*)$ /index.php?/$1 [L]

And it fixed the issue. Like I was stating, the redirect was in my controller, not in my views or anything.


Redirect() not working - El Forum - 09-07-2008

[eluser]M Moeen uddin[/eluser]
I was getting "redirect function not defined"...By reading this post i come to knew that only uri library is not needed but you have to On the Rewrite Engine alo in apache settings.

But this thing does not slove my problem.
Im still getting Call to undefined function redirect().

Kindly help.


Redirect() not working - El Forum - 09-07-2008

[eluser]Sumon[/eluser]
would you please paste your code here.