我目前正在使用codeigniter。我目前可以通过 using 查看个人资料,/user/profile/profile_id但我想这样做,以便用户可以导航到个人资料 using/username以使其更简单。
我将如何去做我不知道从哪里开始?
class User extends CI_Controller{  
public function index(){
    if($this->session->userdata('is_logged_in')){
        redirect('user/profile');
    }
}
public function profile(){
    $profile_id = $this->uri->segment(3);
    $ip = $this->session->userdata('ip_address');
    $curr_user = $this->session->userdata('id');
    $data['profile'] = $this->db->get_where('users', array('id' => $profile_id))->row_array();  
    $data['followers'] = $this->db->get_where('followers', array('following_id' => $profile_id))->num_rows();       
    $data['following'] = $this->db->get_where('followers', array('follower_id' => $profile_id))->num_rows();
    $data['doesFollow'] = $this->db->get_where('followers', array('follower_id' => $curr_user, 'following_id' => $profile_id))->num_rows();
    $data['posts'] = $this->db->get_where('posts', array('user_id' => $profile_id))->result_array();        
    $data['main_content'] = 'profile';  
    $this->load->view('template', $data);   
    $this->get_profile_view($profile_id, $ip, $curr_user);  
}
} 
路由.php
$route['default_controller'] = "signin";
$route['404_override'] = '';