• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
redirect failing on a different server

#1
[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!!

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

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

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

#5
[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')

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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.