title: Codeigniter redirect returns string instead of passing it to the url
body: <p>This is my controller for login using ajax.
  <strong>Login.php</strong></p>
  
  <pre><code>&lt;?php
  defined('BASEPATH') OR exit('No direct script access allowed');
  
  class Login extends CI_Controller {
  
  public function index(){
      $this-&gt;load-&gt;view('login');
  }
  
  public function checkLogin(){
      if($this-&gt;input-&gt;is_ajax_request() &amp;&amp; isset($_POST['email']) &amp;&amp; isset($_POST['password'])){#restrict direct access from browser
          if(empty($this-&gt;input-&gt;post('email')) || empty($this-&gt;input-&gt;post('password'))){
              echo "not";
          }else{
              if(filter_var($this-&gt;input-&gt;post('email'), FILTER_VALIDATE_EMAIL) === false){
                  echo "not";
              }else{
                  $data = array(
                          'email' =&gt; $this-&gt;input-&gt;post('email'),
                          'password' =&gt; md5($this-&gt;input-&gt;post('password'))
                      );
                  if($this-&gt;db-&gt;select('*')&amp;&amp;
                  $this-&gt;db-&gt;from('users')&amp;&amp;
                  $this-&gt;db-&gt;where($data)){
                      if($this-&gt;db-&gt;count_all_results() &gt; 0){
                          redirect('homepage'); #REDIRECT
                      }else{
                          echo "not";
                      }
                  }
  
              }
          }
  
      }else{
          show_error("No direct script access allowed");
      }
  }
  }
  </code></pre>
  
  <p>This is my javascript file:</p>
  
  <pre><code>$(document).ready(function(){
  $("#login-form").submit(function(event){
      event.preventDefault();
      $.ajax({
          url: 'http://citest.local/login/checkLogin',
          type: 'POST',
          data: {
                  email: $.trim($("#email").val()),
                  password: $.trim($("#password").val())},
      })
      .done(function(result) {
          if(result == "not"){
              $(".has-feedback").addClass('has-error');
              $(".glyphicon").addClass('glyphicon-remove');
          }else{
              $(".has-feedback").removeClass('has-error');
              $(".glyphicon").removeClass('glyphicon-remove');
              $(".has-feedback").addClass('has-success');
              $(".glyphicon").addClass('glyphicon-ok');
              console.log(result);
          }
      });
  });
  });
  </code></pre>
  
  <p>this is the result that is returned to the console by the redirect function from my controller:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;
  &lt;title&gt;Simple Contacts&lt;/title&gt;
  &lt;link rel="stylesheet" href=""&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>.htaccess</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
  RewriteEngine On
  RewriteBase /
  
  # Disable rewrite for valid directory/files     
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d 
  
  #map all request urls to a specific controller method
  RewriteRule ^(.*)$ index.php?/{controller}/{method}/$1 [L]
  &lt;/IfModule&gt;
  
  &lt;IfModule !mod_rewrite.c&gt;
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin
  
    ErrorDocument 404 /index.php
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>site config (nginx)</p>
  
  <pre><code>server {
      listen 80;
  
      root /home/user/trytry/ci_test;
      index index.html index.htm index.php;
  
  # Make site accessible from http://localhost/
  server_name citest.local;
  
  # unless the request is for a valid file (image, js, css, etc.), send to bootstrap
  if (!-e $request_filename)
  {
      rewrite ^/(.*)$ /index.php?/$1 last;
      break;
  }   
  
  location / {
      # First attempt to serve request as file, then
      # as directory, then fall back to displaying a 404.
      try_files $uri $uri/ =404;
      # Uncomment to enable naxsi on this location
      # include /etc/nginx/naxsi.rules
  }
  
  # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
  #location /RequestDenied {
  #   proxy_pass http://127.0.0.1:8080;    
  #}
  
  #error_page 404 /404.html;
  
  # redirect server error pages to the static page /50x.html
  #
  #error_page 500 502 503 504 /50x.html;
  #location = /50x.html {
  #   root /usr/share/nginx/html;
  #}
  
  # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  #
  location ~ \.php$ {
      fastcgi_split_path_info ^(.+\.php)(/.+)$;
      # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
  
      # With php5-cgi alone:
  #   fastcgi_pass 127.0.0.1:9000;
      # With php5-fpm:
      fastcgi_pass unix:/var/run/php5-fpm.sock;
      fastcgi_index index.php;
      include fastcgi_params;
  }
  
  # deny access to .htaccess files, if Apache's document root
  # concurs with nginx's one
  #
  #location ~ /\.ht {
  #   deny all;
  #}
  }
  </code></pre>
  
  <p>Why redirect is not working as it supposed to be? It returns string instead of redirecting the url. Please help! :(</p>