1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Redirect users who clicked a hotlinked download

Discussion in 'Blogging' started by h3llr8zr, Oct 23, 2015.

  1. h3llr8zr

    h3llr8zr Registered Member

    Joined:
    Aug 13, 2008
    Messages:
    70
    Likes Received:
    40
    Gender:
    Male
    Occupation:
    Certified Retard
    Location:
    Germany
    Home Page:
    Hello mates,

    I have the problem that the downloads that I offer getting hotlinked by various websites. I know how to redirect these websites but thats not enough, because in a couple of weeks the next hotlinker will appear, and the next and the next. The .htaccess is getting bigger and bigger and will slow down the system.

    Is there a way to only allow visitors of my website to get the file?

    The download link is this: h**p://mydomain.com/?dl=522

    And I thought, that I redirect the users from other websites that have NOT the refer of my domain to my homepage.
    (does the user who clicks my link on my website have the refer of my domain?)

    Is this possible via .htaccess?

    I'm sorry for my english because I am not a native speaker.

    Regards
     
  2. JasonGraham

    JasonGraham Regular Member

    Joined:
    Oct 2, 2015
    Messages:
    322
    Likes Received:
    89
    Ask for a password to download your file, and make the password available on your website and change it every week
    So even if an another website link to your download, he will need the password that is in your website and other websites wont bother to look each week for the new password
    Also include your website adresse in the download, so if someone gets to the download without the password he will go to your website to get it
     
    • Thanks Thanks x 1
  3. Conor

    Conor Jr. VIP Jr. VIP

    Joined:
    Nov 7, 2012
    Messages:
    3,537
    Likes Received:
    5,854
    Gender:
    Male
    Location:
    South Africa
    Home Page:
    Put this together with the help from a few other sites. Not sure if it'll work, but you should get the idea:

    Code:
    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !^http://(.+\.)?example\.com [NC]
    RewriteCond %{HTTP_HOST} ^example\.com [NC]
    RewriteCond %{QUERY_STRING} ^dl=(522)$ [NC]
    RewriteRule (.*) http://www.example.com$1 [R=301,L]
    
     
    • Thanks Thanks x 1
  4. roadhamster

    roadhamster Regular Member

    Joined:
    Mar 12, 2012
    Messages:
    335
    Likes Received:
    242
    Check the referer in PHP, if referer is not from your site then redirect them to a 1000MB file or something.

    PHP:
    <?php
    if($_SERVER['HTTP_REFERER']<>"your_referer")
    {
    header("Location: http://getlostandgohome.com");
    exit();
    }
    ?>
     
    • Thanks Thanks x 2
  5. h3llr8zr

    h3llr8zr Registered Member

    Joined:
    Aug 13, 2008
    Messages:
    70
    Likes Received:
    40
    Gender:
    Male
    Occupation:
    Certified Retard
    Location:
    Germany
    Home Page:
    Thank you very much to all of you.

    The password thingi is a good idea because my plugin has the function to set a password.

    I think I will try the php solution at first because it will fit in my needs almost perfectly.

    Regards