PHP file download issue - stop redirection if file does not exist while using GET method
<p>I have main.php file, on which I have many "sub pages" (there are tabs and you can switch them so <a href="http://mydomain.com/main.php" rel="nofollow">http://mydomain.com/main.php</a> address does not change). I receive them dynamically via ajax requests. On one of such "sub page" I have download links. For example</p>

<pre><code>                  &lt;a href="dwnl.php?file=fish.avi"&gt;fish&lt;/a&gt;
</code></pre>

<p>in dwnl.php file I have something like this</p>

<pre><code> // . . . . .
 $file =basename($_GET['file']);
 if(file_exists($file))
 {
   // download file
 }
 else  exit;
</code></pre>

<p>my problem occurs when file does not exist (i.e. in 'else' block of my dwnl.php file). If users click such link, browser redirects them to <a href="http://mydomain.com/dwnl.php?file=" rel="nofollow">http://mydomain.com/dwnl.php?file=</a>...  address. How can I forbid such redirection? I would like to do it using PHP (if it is possible). So, what should I do in 'else' block? </p>
