I googled my question but it seems there is nothing about it on whole internet!
I have a html link that goes to a php file.That php file redirect to link for downloading a RAR file.But after download i have a page with my php file address that i dont want to be seen.i want to add another header to the php file that redirect to a blank_page that has nothing even a url.
Actually, i see many websites that using this trick,
is there any way to do that with php or js or even jquery and ... ?
this is my php file code:
header('Location: http://~~~~~~.com/xxx.RAR');
You can use this simple JavaScript snippet to edit the browser history + url. The following code will set the URL to the parent domain. "Example: YourDomain.com"
history.replaceState( {} , '', '..' );
You can add this snippet to the onLoad Event of the page.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body onLoad="history.replaceState( {} , '', '..' )">
</body>
</html>
I am not sure I understood it well but would that code serve?
$("#link").click(function() {
location.href = 'http://~~~~~~.com/xxx.RAR';
return false;
});
This jQuery code should be on your html file and will download your file without opening a new window.
Not sure if I got your question but suppose this is your link in your html file using target="_blank" will open a new page
Now if you want to download a file basically you could use something like this:
$file = 'file/file.rar';
if (file_exists($file))
{
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
else
{
echo 'No installation file available for download';
}
Why do you need the php file that redirect to the RAR file in the first place. You may modify your html link point to the RAR file directly.