title: How do i redirect properly in CodeIgniter 3?
body: <p>I am new to codeigniter and I am developing a basic authentication system with session. I am using version <code>3.1.11</code></p>
  
  <p>Please take note that I am developing in my localhost server.</p>
  
  <p><strong>Project url:</strong> <a href="http://localhost/tutorial/codeigniter" rel="nofollow noreferrer">http://localhost/tutorial/codeigniter</a></p>
  
  <p><strong>Login url:</strong> <a href="http://localhost/tutorial/codeigniter/login/index.php/auth/login" rel="nofollow noreferrer">http://localhost/tutorial/codeigniter/login/index.php/auth/login</a></p>
  
  <p><strong>User profile url:</strong> <a href="http://localhost/tutorial/codeigniter/login/index.php/user/profile" rel="nofollow noreferrer">http://localhost/tutorial/codeigniter/login/index.php/user/profile</a></p>
  
  <p><br>
  Also, my login code works.</p>
  
  <p><br>
  <strong>Controller: Auth.php</strong></p>
  
  <pre><code>public function __construct()
  {
    parent::__construct();
    $this-&gt;load-&gt;database();
    $this-&gt;load-&gt;helper('url');
  }
  
  public function login()
  {
    $this-&gt;form_validation-&gt;set_rules("username", "Username", "required");
    $this-&gt;form_validation-&gt;set_rules("password", "Password", "required|min_length[7]");
  
    if($this-&gt;form_validation-&gt;run() == TRUE) {
      ....
      if ($row) {
        $this-&gt;session-&gt;set_flashdata("success", "Success!!!"); 
  
        $_SESSION["user_logged"] = TRUE;
        $_SESSION["username"] = $user-&gt;username;
  
        // redirect to profile page
        redirect('user/profile', 'refresh');
      } else {
        $data['error']="&lt;div class='alert alert-danger'&gt;Invalid login details&lt;/div&gt;";
      }
    }
  
    $this-&gt;load-&gt;view("login", @$data);
  }
  </code></pre>
  
  <p><strong>Controller: User.php</strong></p>
  
  <pre><code>class User extends CI_Controller
  {
    public function profile()
    {
      echo "Profile Page";
    }
  }
  </code></pre>
  
  <p><strong>Problem:</strong> I want to redirect the user to <a href="http://localhost/tutorial/codeigniter/login/index.php/user/profile" rel="nofollow noreferrer">http://localhost/tutorial/codeigniter/login/index.php/user/profile</a> after they have successfully logged in. The code that I use for redirecting is <code>redirect('user/profile', 'refresh');</code></p>
  
  <p>The problem with the redirect code above is that it is redirected to <a href="http://localhost/tutorial/login/index.php/user/profile" rel="nofollow noreferrer">http://localhost/tutorial/login/index.php/user/profile</a> -- The <code>/codeigniter</code> is not included</p>
  
  <p>Do you have any idea how can I redirect to <a href="http://localhost/tutorial/codeigniter/login/index.php/user/profile" rel="nofollow noreferrer">http://localhost/tutorial/codeigniter/login/index.php/user/profile</a> properly? Any help is greatly appreciated. Thanks</p>