Redirect to another URL |
[eluser]jigen7[/eluser]
hi i got a this part of a code to my index in my user controller that redirects it to the login function but i want to do is redirect it to another url not within the site for example http://google.com and i cant find the way to do it can anyone help me through here thanks Code: function index()
[eluser]Randy Casburn[/eluser]
Hi jigen7, The CI redirect function will only work for 'local' uri segments (as you found out) ;-) So you have two choices: 1) use raw PHP Code: header("Location: http://google.com, TRUE, 302"); or 2) use the CI Output Class Code: $this->output->set_header("Location: http://google.com, TRUE, 302"); Randy
[eluser]jigen7[/eluser]
wahh yeah i totally forgot about raw php codes tsk tsk thanks thanks
[eluser]Jamie Rumbelow[/eluser]
But be careful when using raw php - you can't send headers AFTER they've already been sent, so it's usually the best idea to use CI's output class.
[eluser]Sarre[/eluser]
If this is the index from the User controller, and you have to redirect to another function in that same controller, you can just do Code: function index() |
Welcome Guest, Not a member yet? Register Sign In |