title: PHP error: Cannot modify header information without any html/cookie/space
body: <p>I have a strange bug with my script, i just want redirect user if the URL finish by '/' to the same URL without any '/' at the end.</p>
  
  <p>i get this error:</p>
  
  <pre><code>Warning: Cannot modify header information - headers already sent by (output started at /home/httpd/vhosts/xxx/httpdocs/series.php:1) in /home/httpd/vhosts/xxx/httpdocs/series.php on line 7
  
  Warning: Cannot modify header information - headers already sent by (output started at /home/httpd/vhosts/mxxx/httpdocs/series.php:1) in /home/httpd/vhosts/xxx/httpdocs/series.php on line 8
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>&lt;?php
  $urlLast = $_SERVER['REQUEST_URI'];
  $urlLast = substr($urlLast, -1);
  if (($urlLast == '/') &amp;&amp; (!strstr($_SERVER['REQUEST_URI'], 'en-streaming')))
  {
      $newURL = substr($_SERVER['REQUEST_URI'],0,-1).'-en-streaming';
      header("Status: 301 Moved Permanently", false, 301);
      header("Location: ".$newURL."");
  }
  </code></pre>