我是 codeigniter 的新手,我正在開發(fā)一個(gè)帶有會(huì)話的基本身份驗(yàn)證系統(tǒng)。我正在使用版本3.1.11請(qǐng)注意,我正在我的本地主機(jī)服務(wù)器上進(jìn)行開發(fā)。項(xiàng)目網(wǎng)址: http://localhost/tutorial/codeigniter登錄網(wǎng)址: http://localhost/tutorial/codeigniter/login/index.php/auth/login用戶個(gè)人資料網(wǎng)址: http://localhost/tutorial/codeigniter/login/index.php/user/profile另外,我的登錄代碼有效。控制器:Auth.phppublic function __construct(){ parent::__construct(); $this->load->database(); $this->load->helper('url');}public function login(){ $this->form_validation->set_rules("username", "Username", "required"); $this->form_validation->set_rules("password", "Password", "required|min_length[7]"); if($this->form_validation->run() == TRUE) { .... if ($row) { $this->session->set_flashdata("success", "Success!!!"); $_SESSION["user_logged"] = TRUE; $_SESSION["username"] = $user->username; // redirect to profile page redirect('user/profile', 'refresh'); } else { $data['error']="<div class='alert alert-danger'>Invalid login details</div>"; } } $this->load->view("login", @$data);}控制器:User.phpclass User extends CI_Controller{ public function profile() { echo "Profile Page"; }}問題:我想在用戶成功登錄后將用戶重定向到http://localhost/tutorial/codeigniter/login/index.php/user/profile 。我用于重定向的代碼是redirect('user/profile', 'refresh');上面重定向代碼的問題在于,它被重定向到http://localhost/tutorial/login/index.php/user/profile -- The /codeigniteris not included您知道如何正確重定向到http://localhost/tutorial/codeigniter/login/index.php/user/profile嗎?任何幫助是極大的贊賞。謝謝
2 回答
九州編程
TA貢獻(xiàn)1785條經(jīng)驗(yàn) 獲得超4個(gè)贊
請(qǐng)將base_url下方設(shè)置application/config/config.php為 http://localhost/tutorial/codeigniter。這將幫助您修復(fù)錯(cuò)誤。
謝謝
qq_花開花謝_0
TA貢獻(xiàn)1835條經(jīng)驗(yàn) 獲得超7個(gè)贊
您應(yīng)該在 application/config 下的 config.php 中設(shè)置。打開 config.php 并放在下面一行。
$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'].'/tutorial/codeigniter/';
- 2 回答
- 0 關(guān)注
- 143 瀏覽
添加回答
舉報(bào)
0/150
提交
取消
