codeigniter - 为什么我无法进入登录页面?
问题描述
这是我在电脑上唯一能看到的地址http://localhost/onlineExam/login/validate_credentials
找不到对象!
在此服务器上找不到请求的 URL。引用页面上的链接似乎是错误的或过时的。请将该错误通知该页面的作者。
如果您认为这是服务器错误,请联系网站管理员。
错误 404
本地主机
Apache/2.4.39 (Win64) OpenSSL/1.1.1c PHP/7.3.7
class Login extends CI_Controller
{
function index()
{
$data['main_content'] = 'login_form';
$this->load->view('includes/templates', $data);
}
function validate_credentials(){
$this->load->model('user_model');
$query = $this->user_model->validate();
if($query)// if the user's credentials validated...
{
$data = array(
'username' => $this->input->post('username'), 'is_logged_in' => true
);
$this->session->set_userdata($data);
redirect('site/users_area');
}
else{
$this->index();
$data['error'] = 'Invalid Username or Password';
$data['main_content'] = 'login_form';
$this->load->view('includes/templates', $data);
}
}
}
解决方案
请检查根文件夹中是否存在 .htaccess 文件,即根据您的 URL 的“onlineExam”。如果不存在,请使用以下行创建/更新:
RewriteEngine On
RewriteBase /onlineExam/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
之后,还要检查 onlineExam/application/config/config.php 中的 base_url
$config['base_url'] = 'http://localhost/onlineExam';
推荐阅读
- r - 具有两个关键列的gather()
- regex - Hive rlike 匹配词边界
- linux - Can the pktgen tool be used to send different types of network packets on one port?
- macos - Why is Docker producing different images when building my Rust program on macOS versus Ubuntu? Is this a bug in Docker?
- python - sklearn.feature_selection.mutual_info_regression not found
- python - Extra results when querying dataframe?
- python - 错误:在 /tmp/pip-pip-egg-info- 中找到多个 .egg-info 目录
- apache-spark - 截断数据块上的表
- c++ - 我应该在成员变量中存储对 map 的引用吗?
- selenium - AM io.appium.java_client.remote.AppiumCommandExecutor$1 lambda$0