Javascript 如何在CodeIgniter 3中正确重定向?

Javascript 如何在CodeIgniter 3中正确重定向?,javascript,php,html,codeigniter,Javascript,Php,Html,Codeigniter,我是codeigniter的新手,我正在开发一个带有会话的基本身份验证系统。我正在使用版本3.1.11 请注意,我正在本地主机服务器上开发 项目url: 登录url: 用户配置文件url: 此外,我的登录代码也可以工作 控制器:Auth.php public function __construct() { parent::__construct(); $this->load->database(); $this->load->helper('url');

我是codeigniter的新手,我正在开发一个带有会话的基本身份验证系统。我正在使用版本
3.1.11

请注意,我正在本地主机服务器上开发

项目url:

登录url:

用户配置文件url:


此外,我的登录代码也可以工作


控制器:Auth.php

public function __construct()
{
  parent::__construct();
  $this->load->database();
  $this->load->helper('url');
}

public function login()
{
  $this->form_validation->set_rules("username", "Username", "required");
  $this->form_validation->set_rules("password", "Password", "required|min_length[7]");

  if($this->form_validation->run() == TRUE) {
    ....
    if ($row) {
      $this->session->set_flashdata("success", "Success!!!"); 

      $_SESSION["user_logged"] = TRUE;
      $_SESSION["username"] = $user->username;

      // redirect to profile page
      redirect('user/profile', 'refresh');
    } else {
      $data['error']="<div class='alert alert-danger'>Invalid login details</div>";
    }
  }

  $this->load->view("login", @$data);
}
class User extends CI_Controller
{
  public function profile()
  {
    echo "Profile Page";
  }
}
问题:我想在用户成功登录后将其重定向到。我用于重定向的代码是
redirect('user/profile','refresh')

上面的重定向代码的问题是它被重定向到--
/codeigniter
不包括在内


你知道我怎样才能正确地重定向到?非常感谢您的帮助。谢谢

请将
应用程序/config/config.php
下的
基本url设置为
http://localhost/tutorial/codeigniter
。 这将帮助您修复错误


谢谢

请将
应用程序/config/config.php
下的
基本url设置为
http://localhost/tutorial/codeigniter
。 这将帮助您修复错误


谢谢

您应该在application/config下的config.php中进行设置。打开config.php并放在第行下面

$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'].'/tutorial/codeigniter/';

您应该在application/config下的config.php中进行设置。打开config.php并放在第行下面

$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'].'/tutorial/codeigniter/';