0

I had redirected my page like:

redirect(base_url().'user/login/?redirect=site/cart_steps/steps');

and it works fine in localhost and when i uploaded it to server it didnt redirect. I checked all the codes and above this all code executes. But when it comes to redirect the page doesnt redirects. I also tried

redirect(base_url().'user/login?redirect=site/cart_steps/steps');
redirect(base_url().'user/login');
header('Location:'.base_url().'user/login?redirect=site/cart_steps/steps');
header('Location:'.base_url().'user/login');

but the page didn't redirect? and also i checked out this The header function is not working on online server? but it cant help me too.... can any one explain what is the problem here....

Community
  • 1
  • 1
Robz
  • 1,140
  • 3
  • 14
  • 35
  • check for base_url() what it contains and is it containing your server path ? – Rajeev Ranjan Jun 20 '13 at 04:32
  • ya it does...i checked it out..and it is correct – Robz Jun 20 '13 at 04:33
  • 1
    When redirecting with header(), you must be sure nothing is output the browser prior to the redirect. See the php manual for further notes: http://php.net/manual/en/function.header.php As for `redirect()`... is that a function you defined? There's no php function named redirect() I've heard of, or according to the manual. – Surreal Dreams Jun 20 '13 at 04:36
  • redirect() is from the code igniter default library... – Robz Jun 20 '13 at 04:37
  • Sounds like something in the webserver configuration is filtering out headers sent by the scripts. – Barmar Jun 20 '13 at 04:53
  • If you do `echo base_url().'user/login?redirect=site/cart_steps/steps';` does the URL look correct? – Barmar Jun 20 '13 at 04:54
  • ya the url is correct...i did ?redirect=... to redirect the page user/login to ../site/cart_steps/steps after the login is success – Robz Jun 20 '13 at 04:56
  • Check that you do a exit or die just after your header function and check that you do no echo anything before (if something is echo, the header will not work). – MatRt Jun 20 '13 at 23:11

4 Answers4

1

You can use the refresh method like this:

    <?php
        redirect($this->input->server('HTTP_REFERER'), 'refresh'); // refresh the page
    ?>

Another common mistake could be echoing out / printing something before the redirection.

Shina
  • 2,019
  • 2
  • 19
  • 25
Nil'z
  • 7,487
  • 1
  • 18
  • 28
0

I would check your CodeIgniter error logs to verify that particular file isn't throwing any error messages that could tell you what needs fixing.

If you haven't already, you'll probably also want to make sure that the URL helper is loaded. ex:

$this->load->helper('url');
BrendonKoz
  • 463
  • 1
  • 6
  • 18
0

Another solution

<meta http-equiv="refresh" url=http://example.com/"> 
Saurabh Chandra Patel
  • 12,712
  • 6
  • 88
  • 78
0

Try to use like this,

First define your base URL as :

$base_url = "Your base url";

then apply this $base_url variable to your redirect link.

Hope this will help.

Pirates
  • 190
  • 1
  • 10