2016-07-04 08:14
浏览 339


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:


图片转代码服务由CSDN问答提供 功能建议


我有一个html链接转到一个php文件。这个php文件重定向链接下载一个RAR文件。但下载后我有一个页面与我的PHP文件地址,我不想被看到。我想要 在php文件中添加另一个标题,重定向到一个甚至没有url的blank_page。

实际上,我看到许多使用此技巧的网站, < p>有没有办法用php或js甚至jquery和...?

这是我的php文件代码: 标题('位置:http://');

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

4条回答 默认 最新

  • doujiunai2169
    doujiunai2169 2016-07-04 08:44

    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:"

    history.replaceState( {} , '', '..' );

    You can add this snippet to the onLoad Event of the page.

    <!doctype html>
    <meta charset="utf-8">
    <body onLoad="history.replaceState( {} , '', '..' )">
    点赞 评论
  • dt4233
    dt4233 2016-07-04 08:27

    I am not sure I understood it well but would that code serve?

    $("#link").click(function() {
            location.href = '';
            return false;

    This jQuery code should be on your html file and will download your file without opening a new window.

    点赞 评论
  • dongni9825
    dongni9825 2016-07-04 08:28

    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 enter image description here

    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));
        echo 'No installation file available for download';
    点赞 评论
  • dozoqn3347
    dozoqn3347 2016-07-04 10:00

    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.

    点赞 评论