![]() |
Redirect to another URL - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Redirect to another URL (/showthread.php?tid=12606) |
Redirect to another URL - El Forum - 10-24-2008 [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() Redirect to another URL - El Forum - 10-24-2008 [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 Redirect to another URL - El Forum - 10-24-2008 [eluser]jigen7[/eluser] wahh yeah i totally forgot about raw php codes tsk tsk thanks thanks Redirect to another URL - El Forum - 10-25-2008 [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. Redirect to another URL - El Forum - 10-25-2008 [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() |