0

我正在使用 Codeigniter 和 Tank Auth,我正在使用 Ubuntu 操作系统。当我使用我的 IP 访问我的项目时,它类似于:

http://192.168.1.10/project/auth/login

我必须实现使用 URL 搜索配置文件的功能。假设如果我输入

http://192.168.1.10/project/vishmay

然后它应该显示我的个人资料。谁能告诉我该怎么做?

我试过在我的 routes.php 中这样做

$route['default_controller'] = "welcome";
$route['auth/login'] = 'auth/login';
$route['auth/register'] = 'auth/register';
$route['auth/logout'] = 'auth/logout';
$route['welcome/profile'] = 'welcome/profile';
$route[':any'] = 'auth/index/$1';

并且还在 auth.php 控制器中创建了 index()

 function index() {
        $username=$this->uri->segment(1);
        $data['result']=$this->users->get_profile_pic1($username);   
        if ($message = $this->session->flashdata('message')) {
            $data['reg_success'] = "You have been registered successfully.";
            $reg_success = 1;
            redirect('/auth/register', $data);
        } else {
            redirect('/auth/login/');
        }
    }
4

1 回答 1

2

你应该改变:

$route[':any'] = 'auth/index/$1';

$route['(:any)'] = 'auth/index/$1';

使$1能正确获取段值。

你可以试试这段代码:

试试这个:

function index($username = '') {
    $data['result']=$this->users->get_profile_pic1($username);   
    if ($message = $this->session->flashdata('message')) {
        $data['reg_success'] = "You have been registered successfully.";
        $reg_success = 1;
        redirect('/auth/register', $data);
    } else {
        redirect('/auth/login/');
    }
}
于 2013-02-19T06:02:15.013 回答