CodeIgniter Forums
redirect failing on a different server - 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 failing on a different server (/showthread.php?tid=2085)



redirect failing on a different server - El Forum - 07-15-2007

[eluser]Phil Sturgeon[/eluser]
Recently started doing a bit of work for a client and for some reason my redirect does not work when using the URL helper.

The code:

Code:
function index()
    {
        $this->load->helper('url');
        
        $this->load->library('validation');
        
        $rules['emailAddress'] = "trim|required|valid_email";
        $rules['userType'] = "trim|required";

        $this->validation->set_rules($rules);
            
        if ($this->validation->run() == FALSE)
        {
            $this->load->view('splash');
        }
        else
        {
        
            $row = array(
                'email' =>    $this->input->post('emailAddress'),
                'type'    =>    $this->input->post('userType')
            );
        
            $this->db->insert('Subscriptions', $row);
        
            redirect('/splash/thanks');
        }    
    }

this does not work. It takes them back to the splash.php view instead of rediecting to the "splash_thanks.php"

So thats lame!

When I swap:

Code:
redirect('/splash/thanks');
with
Code:
header('Location: /splash/thanks');

it works fine!!


redirect failing on a different server - El Forum - 07-15-2007

[eluser]coolfactor[/eluser]
Use Firefox's Headers feature to monitor what the redirect() function is sending to the browser. It should be using a Location redirect, by default. I use redirect() extensively on my sites, so I don't know why it wouldn't work for you.


redirect failing on a different server - El Forum - 07-15-2007

[eluser]Phil Sturgeon[/eluser]
Exactly. I have used it hell-loads on my two sites and on a few for various clients ALWAYS with no problem. I wouldnt have thought it would matter about PHP versions or anything would it?

It doesnt seem to do anything... just flops. Take a look Kicknote


redirect failing on a different server - El Forum - 07-15-2007

[eluser]coolfactor[/eluser]
I just signed up at Kicknote and saw the Thanks page properly. Was it supposed to not work?

Could it be a browser issue instead? What are you using for a browser?


redirect failing on a different server - El Forum - 07-15-2007

[eluser]the real rlee[/eluser]
Pyro, you running PHP under IIS? Some Windows servers dont like location as noted in docs. Try using 'refresh'

Code:
redirect('mypage', 'refresh')



redirect failing on a different server - El Forum - 07-16-2007

[eluser]Phil Sturgeon[/eluser]
@coolfactor: As I said I changed back to using header('location') shortly after posting as the guy was complaining it wasnt working. Cant make a client unhappy just cause im trying to fix a bit of code >.<

@real rlee: redirect has two options - redirect & location (default). So this cannot be the error as the code that redirect() is using the same method as the one I pasted above... so... wtf?!