尝试将codeigniter应用程序从本地移动到 Cloud ,但收到错误说该页面无效(IP地址)当前无法处理此请求 .
HTTP错误500 .
重命名了Login.php控制器并使其成为login.php,因此出现此错误,否则就说明了
404找不到页面找不到您请求的页面 .
从其他帖子尝试了所有内容,例如将配置文件 $config['uri_protocol'] = 'AUTO';
更改为路径信息,查询字符串,请求uri,orig路径信息但似乎无效 . 对服务器进行了更改,同时启用了mod_rewrite . 下面我附上routes.php,database.php,config.php,index.php和login.php,即控制器 .
routes.php文件
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------------
| URI ROUTING
| -------------------------------------------------------------------------
| This file lets you re-map URI requests to specific controller functions.
|
| Typically there is a one-to-one relationship between a URL string
| and its corresponding controller class/method. The segments in a
| URL normally follow this pattern:
|
| example.com/class/method/id/
|
| In some instances, however, you may want to remap this relationship
| so that a different class/function is called than the one
| corresponding to the URL.
|
| Please see the user guide for complete details:
|
| http://codeigniter.com/user_guide/general/routing.html
|
| -------------------------------------------------------------------------
| RESERVED ROUTES
| -------------------------------------------------------------------------
|
| There area two reserved routes:
|
| $route['default_controller'] = 'welcome';
|
| This route indicates which controller class should be loaded if the
| URI contains no data. In the above example, the "welcome" class
| would be loaded.
|
| $route['404_override'] = 'errors/page_missing';
|
| This route will tell the Router what URI segments to use if those provided
| in the URL cannot be matched to a valid route.
|
*/
$route['default_controller'] = "login";
$route['organizational_structure']='designation/organizational_structure';
$route['timesheet']='dtm/timesheet';
$route['timesheet/time_track']='dtm/time_track';
$route['timesheet/view_time_track']='dtm/view_time_track';
$route['timesheet/schedule']='dtm/schedule';
$route['timesheet/holidays']='dtm/holidays';
$route['404_override'] = 'error_404';
$route['404_override'] = '';
/* End of file routes.php */
/* Location: ./application/config/routes.php */
为database.php
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = '';
$db['default']['database'] = 'latestdb';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
Config.php有一行$ config ['uri_protocol'] ='AUTO';
的index.php
<?php
/*
*---------------------------------------------------------------
* APPLICATION ENVIRONMENT
*---------------------------------------------------------------
*
* You can load different configurations dependihng on your
* current environment. Setting the environmethe codent also influences
* things like logging and error reporting.
*
* This can be set to anything, but default usage is:
*
* development
* testing
* production
*
* NOTE: If you change these, also change the error_reporting() code below
*
*/
define('ENVIRONMENT', 'testing');
/*
*---------------------------------------------------------------
* ERROR REPORTING
*---------------------------------------------------------------
*
* Different environments will require different levels of error reporting.
* By default development will show errors but testing and live will hide them.
*/
if (defined('ENVIRONMENT'))
{
switch (ENVIRONMENT)
{
case 'development':
error_reporting(E_ALL);
break;
case 'testing':
case 'production':
error_reporting(0);
break;
default:
exit('The application environment is not set correctly.');
}
}
/*
*---------------------------------------------------------------
* SYSTEM FOLDER NAME
*---------------------------------------------------------------
*
* This variable must contain the name of your "system" folder.
* Include the path if the folder is not in the same directory
* as this file.
*
*/
$system_path = 'system';
/*
*---------------------------------------------------------------
* APPLICATION FOLDER NAME
*---------------------------------------------------------------
*
* If you want this front controller to use a different "application"
* folder then the default one you can set its name here. The folder
* can also be renamed or relocated anywhere on your server. If
* you do, use a full server path. For more info please see the user guide:
* http://codeigniter.com/user_guide/general/managing_apps.html
*
* NO TRAILING SLASH!
*
*/
$application_folder = 'application';
/*
* --------------------------------------------------------------------
* DEFAULT CONTROLLER
* --------------------------------------------------------------------
*
* Normally you will set your default controller in the routes.php file.
* You can, however, force a custom routing by hard-coding a
* specific controller class/function here. For most applications, you
* WILL NOT set your routing here, but it's an option for those
* special instances where you might want to override the standard
* routing in a specific front controller that shares a common CI installation.
*
* IMPORTANT: If you set the routing here, NO OTHER controller will be
* callable. In essence, this preference limits your application to ONE
* specific controller. Leave the function name blank if you need
* to call functions dynamically via the URI.
*
* Un-comment the $routing array below to use this feature
*
*/
// The directory name, relative to the "controllers" folder. Leave blank
// if your controller is not in a sub-folder within the "controllers" folder
// $routing['directory'] = '';
// The controller class file name. Example: Mycontroller
// $routing['controller'] = '';
// The controller function you wish to be called.
// $routing['function'] = '';
/*
* -------------------------------------------------------------------
* CUSTOM CONFIG VALUES
* -------------------------------------------------------------------
*
* The $assign_to_config array below will be passed dynamically to the
* config class when initialized. This allows you to set custom config
* items or override any default config values found in the config.php file.
* This can be handy as it permits you to share one application between
* multiple front controller files, with each file containing different
* config values.
*
* Un-comment the $assign_to_config array below to use this feature
*
*/
// $assign_to_config['name_of_config_item'] = 'value of config item';
// --------------------------------------------------------------------
// END OF USER CONFIGURABLE SETTINGS. DO NOT EDIT BELOW THIS LINE
// --------------------------------------------------------------------
/*
* ---------------------------------------------------------------
* Resolve the system path for increased reliability
* ---------------------------------------------------------------
*/
// Set the current directory correctly for CLI requests
if (defined('STDIN'))
{
chdir(dirname(__FILE__));
}
if (realpath($system_path) !== FALSE)
{
$system_path = realpath($system_path).'/';
}
// ensure there's a trailing slash
$system_path = rtrim($system_path, '/').'/';
// Is the system path correct?
if ( ! is_dir($system_path))
{
exit("Your system folder path does not appear to be set correctly. Please open the following file and correct this: ".pathinfo(__FILE__, PATHINFO_BASENAME));
}
/*
* -------------------------------------------------------------------
* Now that we know the path, set the main path constants
* -------------------------------------------------------------------
*/
// The name of THIS file
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
// The PHP file extension
// this global constant is deprecated.
define('EXT', '.php');
// Path to the system folder
define('BASEPATH', str_replace("\\", "/", $system_path));
// Path to the front controller (this file)
define('FCPATH', str_replace(SELF, '', __FILE__));
// Name of the "system folder"
define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));
// The path to the "application" folder
if (is_dir($application_folder))
{
define('APPPATH', $application_folder.'/');
}
else
{
if ( ! is_dir(BASEPATH.$application_folder.'/'))
{
exit("Your application folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF);
}
define('APPPATH', BASEPATH.$application_folder.'/');
}
/*
* --------------------------------------------------------------------
* LOAD THE BOOTSTRAP FILE
* --------------------------------------------------------------------
*
* And away we go...
*
*/
require_once BASEPATH.'core/CodeIgniter.php';
/* End of file index.php */
/* Location: ./index.php */
的login.php
<?php
class login extends CI_Controller
{
var $data;
function __construct() {
parent::__construct();
$this->load->helper('cookie');
$this->load->library('session');
$is_admin_logged_in = $this->admin_init_elements->admin_logged_in_status();
global $USER;
if($is_admin_logged_in == TRUE){
redirect('home');
//;
}
//populate viewfor header / footer elements
$this->admin_init_elements->init_elements('N');
$this->load->model('mod_login');
}
function index(){
//if Admin already logged in, send to Admin home
$this->data['message']='';
$this->data['msg_class'] = '';
$post_array=$this->input->post();
$data['old_images']=$this->mod_common->getBgImages();
if($this->input->cookie('remember') == 'on')
{
//echo $this->input->cookie('username');
$this->data['message']=strip_tags($this->mod_login->check_cookie_login());
if($this->data['message']=='Login Successful'){
$this->data['msg_class'] = 'sukses';
redirect('home');
}else{
$this->data['msg_class'] = 'gagal';
}
}
if($this->input->post('action')=='adminLogin'){
//print_r($this->input->post()); die;
if(isset($post_array['remember'])){
$username_cookie= array(
'name' => 'uusername',
'value' => $post_array['username'],
'expire' => '865000',
'secure' => FALSE
);
$password_cookie= array(
'name' => 'userpass',
'value' => $post_array['userpass'],
'expire' => '865000',
'secure' => FALSE
);
$remember_cookie= array(
'name' => 'remember',
'value' => 'on',
'expire' => '865000',
'secure' => FALSE
);
$this->input->set_cookie($username_cookie);
$this->input->set_cookie($password_cookie);
$this->input->set_cookie($remember_cookie);
//die;
}
else
{
if($this->input->cookie('remember') == 'on')
{
if($this->input->cookie('uusername') != $post_array['username'])
{
delete_cookie("remember");
delete_cookie("uusername");
delete_cookie("userpass");
}
}
}
$this->data['message']=strip_tags($this->mod_login->validate_admin_login());
if($this->data['message']=='Login Successful'){
$this->data['msg_class'] = 'sukses';
$companyName = $this->input->post('company');
//echo $companyName;
//$this->session->set_userdata($companyName);
$this->session->set_userdata(array(
'company' => $companyName
));
//$this->load->database($companyName, TRUE);
//print_r($this->session->userdata);
//die;
redirect('home');
}else{
$this->data['msg_class'] = 'gagal';
}
} /*else if(isset()){
}*/
///////////////////////
$this->data['cookieRemember'] = $this->input->cookie('remember');
$this->data['cookieUsername'] = $this->input->cookie('username');
$this->data['cookiePassword'] = $this->input->cookie('userpass');
//echo $this->data['cookieRemember'];echo $this->data['cookieUsername']; echo $this->data['cookiePassword'];
//////////////////////
$this->data['cookiename'] = $this->input->cookie('name', false);
$this->data['cookieimage'] = $this->input->cookie('image', false);
$sess_msg = $this->session->userdata('session_msg');
$session_msg_class = $this->session->userdata('session_msg_class');
if(isset($sess_msg) && $sess_msg!= ''){
$this->data['message']=$sess_msg;
$this->data['msg_class'] = $session_msg_class!=''?$session_msg_class:'gagal';
}
//render full layout, specific to this function
$this->load->view('login', $this->data);
}
////////////////////////////////////////////////////////////////////////////////
function forgot_password(){
$this->load->view('send_reset_link', $this->data);
}
function send_pass_reset_link(){
$post_array=$this->input->post();
if($post_array['email']!='') {
$email_id=$post_array['email'];
$user_id=$this->mod_common->get_userid($post_array['email']);
foreach($user_id as $key){
$id=$key['id'];
}
if($id>0){
$link=base_url().'login/reset_password/'.$id;
$message_body="<table>
<tr><td style='padding:10px 0px'>Dear User,</td></tr>
<tr><td style='padding:10px 0px'>You have received this communication in response to your request to reset your online portal account password. Please find below the link to reset your password</td></tr>
<tr ><td style='padding:10px 0px'><a href='".$link."' style='background:#86c337;text-decoration:none;padding:5px 10px;color:#fff'> Reset Password </a></td></tr>
<tr ><td style='padding:10px 0px'>Regards,<br>Unfold</td></tr>
</table>";
/*-------------------------*/
//sending pass reset mail
$this->load->library('email');
$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$config['mailtype'] = 'html';
$this->email->initialize($config);
$this->email->set_newline("\r\n");
$this->email->from("info@unfold.com","Admin");//email id and name of the sender
$this->email->to($email_id); // email id of the recipient
$this->email->subject("Reset Password"); //The subject line
$this->email->message($message_body);
$this->email->send();
//$this->email->clear();
//show_error($this->email->print_debugger());
//die;
/*-------------------------*/
$this->data['reset_link_msg']="An email with the password reset link has been sent to your mail address.";
}else{
$this->data['reset_link_msg']="Sorry! The email entered is not in our database.";
}
} else {$this->data['reset_link_msg'] = '';}
$this->load->view('send_reset_link', $this->data);
}
function reset_password(){
if($this->input->post()){
$post_array=$this->input->post();
$this->data['reset_msg']=$this->mod_common->reset_password($post_array);
$this->load->view('reset_password', $this->data);
}
if($this->uri->segment(3)!=''){
$this->data['id']=$this->uri->segment(3);
$this->load->view('reset_password', $this->data);
}
else{
redirect('login');
}
}
// Admin authentication ----------
}
?>
的.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
</IfModule>
apache错误日志包含一些错误,如下所示
PHP致命错误:未捕获错误:在/var/www/html/singlecodebase/Feb152017/application/controllers/login.php:10 \ nStack trace中调用null上的成员函数admin_logged_in_status():\ n#0 / var / www / html / singlecodebase / Feb152017 / system / core / CodeIgniter.php(308):login - > __ construct()\ n#1 /var/www/html/singlecodebase/Feb152017/index.php(202):require_once(' /var/www/html/s...')\n#2 \ n在第10行的/var/www/html/singlecodebase/Feb152017/application/controllers/login.php中抛出
在登录控制器中注释了该行,但仍然无效 . 请帮忙
我在localhost上使用这些版本 - 当前PHP版本:5.6.31,Codeigniter版本2.1.3,Mysql版本10.1.25-MariaDB
在数字海洋服务器版本:5.7.19-0ubuntu0.16.04.1 - (Ubuntu)