CodeIgniter - Page Redirection
Syntax | redirect($uri = '', $method = 'auto', $code = NULL) |
Parameters |
|
Return type | void |
Example
<?php
class Redirect_controller extends CI_Controller {
public function index() {
/*Load the URL helper*/
$this->load->helper('url');
/*Redirect the user to some site*/
redirect('http://www.tutorialspoint.com');
}
public function computer_graphics() {
/*Load the URL helper*/
$this->load->helper('url');
redirect('http://www.tutorialspoint.com/computer_graphics/index.htm');
}
public function version2() {
/*Load the URL helper*/
$this->load->helper('url');
/*Redirect the user to some internal controller’s method*/
redirect('redirect/computer_graphics');
}
}
?>
$route['redirect'] = 'Redirect_controller';
$route['redirect/version2'] = 'Redirect_controller/version2';
$route['redirect/computer_graphics'] = 'Redirect_controller/computer_graphics';
http://yoursite.com/index.php/redirect
http://yoursite.com/index.php/redirect/computer_graphics