语法
|
重定向($uri = '', $method = 'auto', $code = NULL) |
Parameters
|
$uri (string)-URI 字符串 $method (string)-重定向方法(‘auto’、‘location’或‘refresh’) $code (string)-HTTP 响应代码(通常为 302 或 303) |
Return Type
|
void |
<?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.lidihuo.com'); } public function computer_graphics() { /*Load the URL helper*/ $this->load->helper('url'); redirect('http://www.lidihuo.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