[英]Unable to redirect to a new page - CodeIgniter
我有一個可以正常使用的登錄系統,但是在重定向功能上卻給我錯誤The requested URL "http://localhost/musiclear/index.php/welcome" cannot be found or is not available. Please check the spelling or try again later.
The requested URL "http://localhost/musiclear/index.php/welcome" cannot be found or is not available. Please check the spelling or try again later.
這是我使用它的地方(login.php):
function validate_credentials() {
$this->load->model('membership_model');
$query = $this->membership_model->validate();
if ($query) { // if users credentials validated
$data = array('usernames' => $this->input->post('username'),
'is_logged_in' => true);
$this->session->set_userdata($data); //set session data
redirect('welcome', 'refresh'); //redirect to home page
} else { //incorrect username or password
$this->index();
}
}
這是我將其定向到(welcome.php)的位置:
class Welcome extends CI_Controller {
public function index() {
$this->home();
}
public function home() {
$this->load->model('model_users');
$data['title'] = 'MVC Cool Title'; // $title
$data['page_header'] = 'Intro to MVC Design';
$data['firstnames'] = $this->model_users->getFirstNames();
// just stored the array of objects into $data['firstnames] it will be accessible in the views as $firstnames
$data['users'] = $this->model_users->getUsers();
$this->load->view('home_view', $data);
}
}
我認為這是路徑的錯誤之處,或鏈接到的地方但我不確定。 這是我的目錄設置:
有人可以告訴我出什么問題了,如何將其鏈接到我的頁面嗎? 非常感謝
您是否在應用程序文件夾中創建了.htaccess?
也許這可以為您的項目工作:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /musiclear/index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /musiclear/index.php
</IfModule>
別客氣
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.