title: PHP header ('Location: ..') Not working on server
body: <p>I'm new to PHP. PHP header should redirect to specific page, but in my case PHP redirect is working on localhost fine but when I deploy the same code into server it is not working in the server and throwing a blank page. I also tried the below suggestions:</p>
  <ul>
  <li><a href="https://stackoverflow.com/questions/11176032/redirect-function-is-not-working-on-the-live-server-but-working-on-localhost">Redirect function is not working on the live server. But working on localhost</a></li>
  <li><a href="https://stackoverflow.com/questions/2710079/php-header-location-redirect-doesnt-work-why">PHP header location-redirect doesn&#39;t work - why?</a></li>
  </ul>
  <p>Which did't help in my case.</p>
  <pre><code>&lt;?php
  
   include('../config/db.html'); 
   
  if(!isset($_SESSION)){
      session_start();
  }  
  $msgsuccess = '';
  
  if(!empty($_GET['msgsuccess'])){
      $msgsuccess = $_GET['msgsuccess'];
  }
  if(isset($_POST) &amp;&amp; !empty($_POST)){
      if(!empty($_GET['url'])){ 
          $url = $_GET['url'];
      }
                          
      if(!empty($_POST['password'])){
          $pass = md5($_POST['password']);
      }
      if(!empty($_POST['username'])){
          $email = trim($_POST['username']);
      }
      $query = &quot;select * from users where email = '$email' and password = '$pass'&quot;;
      $exec_query = mysql_query($query);
      $row = mysql_fetch_array($exec_query);
      if(!empty($row)){
          $_SESSION['adminfirstname'] = $row['firstname'];
          $_SESSION['adminID'] = $row['id'];
          $_SESSION['logged_in_admin'] = true;
          $host  = $_SERVER['HTTP_HOST'];
          $uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
          $extra = 'index.htm';
          header(&quot;Location: http://$host$uri/$extra&quot;);
           die();
      }
      else{
          $msgsuccess = 'INVALID CREDENTIALS!! PLEASE ENTER VALID EMAIL OR PASSWORD';
      }
  }
  
  
  ?&gt;
  </code></pre>
  <p>Thanks in advance.</p>