2016-06-29 207 views
1

訪問URL-http://localhost:82/admin/login 然後 - 我收到404 「找不到網頁錯誤」 找不到 i.e-笨:404呼叫控制器

對象!

在此服務器上找不到請求的URL。如果您手動輸入網址 ,請檢查拼寫並重試。

如果您認爲這是服務器錯誤,請與網站管理員聯繫。

錯誤404

本地主機 阿帕奇/ 2.4.9(Win32的)的OpenSSL/0.9.8y PHP/27年4月5日

我的config.php

$config['base_url'] = 'http://localhost:82/admin'; 
 

 
/* 
 
|-------------------------------------------------------------------------- 
 
| Index File 
 
|-------------------------------------------------------------------------- 
 
| 
 
| Typically this will be your index.php file, unless you've renamed it to 
 
| something else. If you are using mod_rewrite to remove the page set this 
 
| variable so that it is blank. 
 
| 
 
*/ 
 
$config['index_page'] = ''; 
 

 
/* 
 
|-------------------------------------------------------------------------- 
 
| URI PROTOCOL 
 
|-------------------------------------------------------------------------- 
 
| 
 
| This item determines which server global should be used to retrieve the 
 
| URI string. The default setting of 'REQUEST_URI' works for most servers. 
 
| If your links do not seem to work, try one of the other delicious flavors: 
 
| 
 
| 'REQUEST_URI' Uses $_SERVER['REQUEST_URI'] 
 
| 'QUERY_STRING' Uses $_SERVER['QUERY_STRING'] 
 
| 'PATH_INFO'  Uses $_SERVER['PATH_INFO'] 
 
| 
 
| WARNING: If you set this to 'PATH_INFO', URIs will always be URL-decoded! 
 
*/ 
 
$config['uri_protocol'] \t = 'REQUEST_URI';

我的routes.php

$route['default_controller'] = 'admin/index'; 
 
$route['404_override'] = ''; 
 
//$route['translate_uri_dashes'] = FALSE; 
 

 

 
/*admin*/ 
 
//$route['admin'] = 'user/index'; 
 
//$route['admin/signup'] = 'user/signup'; 
 
//$route['admin/create_member'] = 'user/create_member'; 
 
$route['admin'] = 'admin'; 
 
//$route['admin/logout'] = 'admin/logout'; 
 

 

 
$route['package'] = 'package';

我控制器admin.php的

<?php 
 
defined('BASEPATH') OR exit('No direct script access allowed'); 
 

 
class Admin extends CI_Controller { 
 

 
\t /** 
 
\t * Index Page for this controller. 
 
\t * 
 
\t * Maps to the following URL 
 
\t * \t \t http://example.com/index.php/admin 
 
\t * \t - or - 
 
\t * \t \t http://example.com/index.php/admin/index 
 
\t * \t - or - 
 
\t * Since this controller is set as the default controller in 
 
\t * config/routes.php, it's displayed at http://example.com/ 
 
\t * 
 
\t * So any other public methods not prefixed with an underscore will 
 
\t * map to /index.php/welcome/<method_name> 
 
\t * @see https://codeigniter.com/user_guide/general/urls.html 
 
\t */ 
 
     function __construct() { 
 
     parent::__construct(); 
 
     $this->load->helper('url'); 
 
     $this->load->helper('form'); 
 
     $this->load->model('LoginModel'); 
 
     $this->load->library('session'); 
 
    } 
 
     
 
     
 
    
 
\t public function index() 
 
\t { 
 
      if($this->session->userdata('is_logged_in')){ 
 
\t \t \t redirect('package/packages'); 
 
     }else{ 
 
     \t $this->load->view('admin/admin'); \t 
 
     } 
 
\t \t 
 
\t } 
 
      function __encrip_password($password) { 
 
     return md5($password); 
 
    } \t 
 
     /** 
 
    * check the username and the password with the database 
 
    * @return void 
 
    */ 
 
     public function login() 
 
\t { \t 
 
     echo "hi"; exit; 
 
\t \t 
 

 
\t \t $user_name = $this->input->post('username'); 
 
\t \t $password = $this->__encrip_password($this->input->post('password')); 
 

 
\t \t $is_valid = $this->LoginModel->validate($user_name, $password); 
 
\t \t 
 
\t \t if($is_valid) 
 
\t \t { 
 
\t \t \t $data = array(
 
\t \t \t \t 'user_name' => $user_name, 
 
\t \t \t \t 'is_logged_in' => true 
 
\t \t \t); 
 
\t \t \t $this->session->set_userdata($data); 
 
\t \t \t redirect('package/package'); 
 
\t \t } 
 
\t \t else // incorrect username or password 
 
\t \t { 
 
\t \t \t $data['message_error'] = TRUE; 
 
\t \t \t $this->load->view('admin/admin', $data); \t 
 
\t \t } 
 
\t } 
 
     
 
     
 

 
    
 
\t 
 
\t \t 
 

 
    /** 
 
    * The method just loads the signup view 
 
    * @return void 
 
    */ 
 
}

+0

顯示控制器代碼和URL試圖訪問 –

+0

我說有問題 – dpkrai96

+0

網址我使用什麼版本的CI – user4419336

回答

0

可能是你的.htaccess爲您的控制器看起來很好,但你仍是得到這樣的回答。請嘗試在根目錄中添加.htaccess。

0

routes.php文件

$route['default_controller'] = 'admin/index'; 

猜測它應該是什麼?

$route['default_controller'] = 'admin';