0
방랑제 (puphpet로 만든 기계)와 함께 CodeIgniter를 사용하려고합니다.CodeIgniter Vagrant Redirection Loop
IP 주소 192.168.56.101
내가 메인 페이지에 액세스하려고 할 때 나는 VM 내에서 액세스 할 때이 코드가 작동 /index.php/login
에 루프 리디렉션을 얻을 수 있지만, 호스트 브라우저 내에서 내가 할
Refresh:0;url=http://192.168.56.101/index.php/login
그리고 일부 구성 설정 :
루프는 ... 여기 는 응답에서 헤더입니다// application/config/config.php
$config['base_url'] = 'http://192.168.56.101/';
$config['index_page'] = 'index.php';
아이디어가 있으십니까? 필요한 경우 더 많은 코드를 게시 할 수 있습니다. 감사
편집 : 요청에 따라, 여기에 더 많은 정보를 정기적으로 :
//index.php
define('ENVIRONMENT', 'development');
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_path = 'system';
$application_folder = 'application';
if (defined('STDIN'))
{
chdir(dirname(__FILE__));
}
if (realpath($system_path) !== FALSE)
{
$system_path = realpath($system_path).'/';
}
$system_path = rtrim($system_path, '/').'/';
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));
}
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
define('EXT', '.php');
define('BASEPATH', str_replace("\\", "/", $system_path));
define('FCPATH', str_replace(SELF, '', __FILE__));
define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));
if (is_dir($application_folder))
{
define('APPPATH', $application_folder.'/');
}
else
{
if (! is_dir(BASEPATH.$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.'/');
}
require_once BASEPATH.'core/CodeIgniter.php';
주제어 :
// application/controller/login.php
class Login extends CI_Controller
{
public function index()
{
$username = $this->session->userdata('username');
if ($username === false) {
$view_data = array();
$view_data['alert'] = $this->session->flashdata('alert');
$this->load->view('login',$view_data);
}
else {
redirect('home', 'refresh');
}
}
public function connect() {
$this->load->model('user_model');
$username = $this->session->userdata('username');
if ($username === false) {
$post_username = $this->input->post('username');
$post_password = $this->input->post('password');
$data_bdd = $this->user_model->get_user($post_username);
$this->session->set_flashdata('alert', 'user unknown');
foreach ($data_bdd as $user) {
$this->session->flashdata('alert');
if ($this->encrypt->decode($user->USER_PASSWORD) == $post_password) {
$this->session->set_userdata('username',$post_username);
}
else{
$this->session->set_flashdata('alert', 'incorrect password');
}
}
}
redirect('login', 'refresh');
}
public function disconnect() {
$this->session->unset_userdata('username');
redirect('login', 'refresh');
}
}
기본 컨트롤러는 무엇입니까? 사용자가 로그인하지 않은 경우 로그인 컨트롤을 리디렉션합니까? 해당 인덱스 기능을 알려주십시오. –
@ShaifulIslam : 업데이트되었습니다. 어떻게 생각하십니까? – nobe4
나는 항상 login form.may를 보여줄 것이라고 생각한다. $ this-> session-> set_userdata ('username', $ post_username); –