Welcome Guest, Not a member yet? Register   Sign In
Redirect() not working
#1

[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?
#2

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

[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);
#4

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

[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?
#6

[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.
#7

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

[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.
#9

[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.
#10

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




Theme © iAndrew 2016 - Forum software by © MyBB