我登录后很快就收到此错误。
未找到
在此服务器上找不到请求的URL / beat / home / userhome。
控制器 - home.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');class Home extends CI_Controller {
/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* @see http://codeigniter.com/user_guide/general/urls.html
*/
public function index()
{
/*$CURRENT_URL='http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
$CURRENT_URL=str_replace("/index.php", "", $CURRENT_URL);
if($this->session->userdata('CURRENT_URL')){
if($this->session->userdata('CURRENT_URL')!=$CURRENT_URL){
$this->session->set_userdata('CURRENT_URL', $CURRENT_URL);
} else {
redirect($this->session->userdata('CURRENT_URL'), 'refresh');
}
} else {
$this->session->set_userdata('CURRENT_URL', $CURRENT_URL);
}
*/
$this->load->model('log_model');
$this->log_model->update();
$pageData=array('formError'=>'');
if($this->input->post('submit')){
$this->form_validation->set_rules('userid', 'Username', 'trim|required');
$this->form_validation->set_rules('password', 'Password', 'trim|required');
if ($this->form_validation->run() == TRUE){
$this->load->model('user_model');
if($this->user_model->check_login()){
$this->log_model->updatelogin();
redirect('home/userhome', 'refresh');
} else {
$pageData=array('formError'=>'Invalid username/password.');
$this->load->view('index', $pageData);
}
} else {
$this->load->view('index', $pageData);
}
} else {
$this->load->view('index', $pageData);
}
}
function changepassword(){
if($this->checklogin()==false){ $this->logout();}
$pageData=array();
if($this->input->post('submit')){
$this->load->model('user_model');
$pageData['status']=$this->user_model->changepassword();
}
$this->load->view('header');
$this->load->view('changepassword', $pageData);
$this->load->view('footer');
}
function test(){
/*$this->load->model('client_db_model');
$cdb=$this->client_db_model->connect(104);
$res=$cdb->query('CALL msp()');
print_r($res->result());*/
$this->load->view('advtable');
}
function logout(){
$this->session->unset_userdata('company_id');
$this->session->unset_userdata('user_id');
$this->session->unset_userdata('user_name');
$this->session->unset_userdata('CURRENT_URL');
$this->load->model('log_model');
$this->log_model->updatelogout();
//$_SESSION['CURRENT_URL']=base_url();
redirect('./', 'refresh');
}
function checklogin(){
return ($this->session->userdata('company_id')*1>0)?true:false;
}
public function userhome(){
if($this->checklogin()==false){ $this->logout();}
$this->checkmaintenance();
$this->load->model('user_model');
$pageData['lentmenu']='userhome';
$pageData['dashboards']=$this->user_model->getdashboards();
$this->load->view('header', $pageData);
$this->load->view('userhome');
$this->load->view('footer');
}
public function uploadfiles(){
//$this->session->set_userdata(array('company_id'=>0));
if($this->checklogin()==false){ $this->logout();}
$this->checkmaintenance();
$this->load->model('user_model');
$pageData['lentmenu']='uploadfiles';
$pageData['dashboards']=$this->user_model->getdashboards();
$this->load->view('header', $pageData);
$this->load->view('uploadfiles');
$this->load->view('footer');
}
public function dashboard($dashboard_id=NULL){
if($this->checklogin()==false){ $this->logout();}
$this->checkmaintenance();
$this->load->model('user_model');
$pageData['lentmenu']='dashboard';
$_SESSION['dashboard_id']=$dashboard_id;
/*$pageData['dashboards']=$this->user_model->getdashboards();
$pageData['smallboxes']=$this->user_model->getsmallboxes($dashboard_id);*/
$pageData['comments']=$this->user_model->getcomments($dashboard_id);
$pageData['dashboard_id']=$dashboard_id;
$this->load->view('header', $pageData);
$this->load->view('dashboard');
$this->load->view('footer');
}
public function getchart($dashboardwidget_id){
if($this->checklogin()==false){ $this->logout();}
$this->checkmaintenance();
$this->load->model('user_model');
$rtnVar=$this->user_model->getchart($dashboardwidget_id);
echo json_encode($rtnVar);
}
public function postcomment(){
if($this->checklogin()==false){ $this->logout();}
//$this->checkmaintenance();
$this->load->model('user_model');
$rtnVar=$this->user_model->postcomment();
echo json_encode($rtnVar);
}
public function createpdf(){
if($this->checklogin()==false){ $this->logout();}
$this->load->helper('pdf_helper');
/*
---- ---- ---- ----
your code here
---- ---- ---- ----
*/
$this->load->view('pdfreport');
}
function pdf($dashboard_id)
{
if($this->checklogin()==false){ $this->logout();}
$this->load->model('user_model');
$pageData['lentmenu']='dashboard';
$pageData['dashboards']=$this->user_model->getdashboards();
$pageData['comments']=$this->user_model->getcomments($dashboard_id);
$pageData['dashboard_id']=$dashboard_id;
$html=$this->load->view('dashboard');
$this->load->helper(array('dompdf', 'file'));
// page info here, db calls, etc.
//$html = $this->load->view('controller/viewfile', $data, true);
$html=$this->input->post('pdfContent');
pdf_create($html, 'filename');
/*or
$data = pdf_create($html, '', false);
write_file('name', $data);*/
//if you want to write it to disk and/or send it as an attachment
}
function getsectionsmallbox($section_id){
$this->load->model('user_model');
$rtnVal=$this->user_model->getsectionsmallbox($section_id);
echo json_encode($rtnVal);
}
function getsectiontablewidget($section_id){
$this->load->model('user_model');
$rtnVal=$this->user_model->getsectiontablewidget($section_id);
echo json_encode($rtnVal);
}
function getsectionwidget($section_id){
$this->load->model('user_model');
$rtnVal=$this->user_model->getsectionwidget($section_id);
echo json_encode($rtnVal);
}
function getfilters($dashboard_id){
if($this->checklogin()==false){ $this->logout();}
$this->load->model('user_model');
$rtnVal=$this->user_model->getfilters($dashboard_id);
echo json_encode($rtnVal);
}
function checkmaintenance(){
$this->load->model('user_model');
$maintenance=$this->user_model->checkmaintenance();
if($maintenance){
redirect('./home/undermaintenance', 'refresh');
}
}
function undermaintenance(){
$pageData['undermaintenance']=true;
$this->load->view('header', $pageData);
$this->load->view('undermaintenance');
$this->load->view('footer');
}
function advtable(){
$this->load->view('advtable');
}
function edittable(){
if($this->checklogin()==false){ $this->logout();}
$this->checkmaintenance();
$pageData=Array();
$this->load->model('user_model');
$this->load->view('header', $pageData);
$this->load->view('edittable');
$this->load->view('footer');
}
function getedittabledata(){
$this->load->model('user_model');
$tableData=$this->user_model->getedittabledata();
echo json_encode($tableData);
}
function getedittabledatasave(){
$this->load->model('user_model');
$tableData=$this->user_model->getedittabledatasave();
echo json_encode($tableData);
}
function getedittabledataupdate(){
$this->load->model('user_model');
$tableData=$this->user_model->getedittabledataupdate();
echo json_encode($tableData);
}
function getedittabledatadelete(){
$this->load->model('user_model');
$tableData=$this->user_model->getedittabledatadelete();
echo json_encode(array('success'=>true));
} }
答案 0 :(得分:0)
试试这个网址请index.php / beat / home / userhome或 试试这个请你的基础网址后的index.php,请从route.php重新路由,这是正确的方法
答案 1 :(得分:0)
首先将此代码放在root
上的.htaccess文件中DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?$1 [L,QSA]
检查类文件名。
设置配置文件
答案 2 :(得分:0)
首先:尝试CodeIgniter中的默认网址:beat / index.php / home / userhome
如果仍然无效,请尝试routing:
路由:config / routes.php
$route['home/userhome'] = 'home/userhome';
如果有效,则可以从网址read this中删除 index.php 。
还有一件事:我不知道你正在使用什么版本。如果您使用的是CodeIgniter 3.0,则需要更改文件名read more about Style Guide。