CodeIgniter重定向方法不起作用

i am new to codeigniter. i am creating a login form and process. However when it finds all the data matched from databse it has to redirect to a page (v_home). but it displays this error.

The requested URL /CodeIgniter/c_home was not found on this server.

my code is

**my form **

 <?php echo validation_errors(); ?>
 <?php echo form_open('c_verifylogin/index');
   echo form_label("Username: ");
   echo form_input("username");
   echo "<br>";
   echo form_label("Password: ");
   echo form_password("password");
   echo "<br>";
   echo form_submit("","Login");
   echo form_close();

?>

the varify class

class C_verifyLogin extends CI_Controller {
function __construct() {
    parent::__construct();
    //load session and connect to database
    $this->load->model('m_login','login',TRUE);
    $this->load->helper(array('form', 'url','html'));
    $this->load->library(array('form_validation','session'));
}

function index() {
    $this->form_validation->set_rules('username', 'Username', 'trim|required|xss_clean');
    $this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean|callback_check_database');

    if($this->form_validation->run() == FALSE) {
      $this->load->view('v_login');
        } else {
            //Go to private area 
           redirect(base_url('c_home'), 'refresh');
             $this->load->view('v_home');
        }       
 }

 function check_database($password) {
     //Field validation succeeded.  Validate against database
     $username = $this->input->post('username');

     //query the database
     $result = $this->login->login($username, $password);
     if($result) {
         $sess_array = array();
         foreach($result as $row) {
             //create the session
             $sess_array = array( 'username' => $row->username);
             //set session with value from database
             $this->session->set_userdata('logged_in', $sess_array);
             }
      return TRUE;
      } else {
          //if form validate false
          $this->form_validation->set_message('check_database', 'Invalid username or password');
          return FALSE;
      }
  }

}

` <?php 
  function index() {
    $this->form_validation->set_rules('username', 'Username','trim|required|xss_clean');
    $this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean|callback_check_database');

    if($this->form_validation->run() == FALSE) {
      $this->load->view('v_login');
        } else {
            //Go to private area 
           **redirect(base_url('c_home'), 'refresh');**

        }       
 }

Here V_home is View home page and c_home is a controller for it.Help will be appriciated

pass the name of the class and the function directly to the redirect function:

redirect('c_home/index', 'refresh');

You have used the redirect method wrong way. Redirect method takes the controller and its function as the parameter.

Suppose you have a separate controller to load the c_home view as shown below.

class C_Home extends CI_Controller {

public function index() {
        $this->load->view('c_home');  
 }

}

Then from any other controller you can call redirect method as show below the load the c_home view.

redirect('c_home','refresh');

You just have to give the name of the controller since loading view function is namedindex. Otherwise if the function has a different name it will like this.

 redirect('c_home/someName','refresh');

So basically redirect method takes controller/method.

There are two possible ways of making this work. Either use the following code

redirect(base_url('index.php/c_home','refresh');

Else go to config directory and open routes.php There change your default controller with the current one and use the following code

redirect(base_url(),'refresh')

Remember, whatever you load into the url in codeigniter must be via a controller, so for the second method make c_home the default controller.

Try this

 redirect(site_url('c_home'), 'refresh');