1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Stopping people from linking files on your site to their site

Discussion in 'Software Development' started by Akito, Jul 19, 2003.

Thread Status:
Not open for further replies.
Advertisement
  1. Akito

    Akito Thread Starter

    Joined:
    May 23, 2003
    Messages:
    931
    I run a music website, and I am finding that people are using my bandwidth by linking the files from my site to their site (Does that make any sense?). It want to stop this, because it's wasting my money. I would like it so if they try to link a file it says "Linking file from x site" or something like that (geocities does this with images). I know its possible just not sure how.
     
  2. brendandonhu

    brendandonhu

    Joined:
    Jul 8, 2002
    Messages:
    14,681
    What serverside languages do you have access to?

    Or are you running on an Apache server? if you are I think you can use htaccess to do this.
     
  3. Akito

    Akito Thread Starter

    Joined:
    May 23, 2003
    Messages:
    931
    I am in fact running apache, and I have access to PHP and Perl (I prefer PHP though, since I'm rusty with perl)

    Thanks!
     
  4. brendandonhu

    brendandonhu

    Joined:
    Jul 8, 2002
    Messages:
    14,681
    Create a file called .htaccess, and put this in it
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?nerocom\.us/
    RewriteRule \.(mp3)$ - [F]
    it should stop remote loading of MP3 files.
     
  5. Akito

    Akito Thread Starter

    Joined:
    May 23, 2003
    Messages:
    931
    Hmm.. it's actually midi files.

    Anyways, it didn't stop it, (I changed it to (mid) but was still able to link from other places)
     
  6. brendandonhu

    brendandonhu

    Joined:
    Jul 8, 2002
    Messages:
    14,681
    Try this one, slightly different
    btw I don't know exactly what these htaccess options are-Im just getting them from google.

    RewriteEngine on

    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?nerocom.us/.*$ [NC]
    RewriteRule \.(mid)$ - [F]
     
  7. Akito

    Akito Thread Starter

    Joined:
    May 23, 2003
    Messages:
    931
    Well they can't link now but they can embed files...
     
  8. brendandonhu

    brendandonhu

    Joined:
    Jul 8, 2002
    Messages:
    14,681
    Maybe you need to CHMOD the files to something so they can only be read by your site-I'm not really sure. Im looking it up though.
     
  9. brendandonhu

    brendandonhu

    Joined:
    Jul 8, 2002
    Messages:
    14,681
    Lets try adding this to your htaccess

    SetEnvIfNoCase Referer "^http://www\.nerocom\.us" hotlinker
    <FilesMatch "\.(mid|)$">
    Deny from hotlinker
    </FilesMatch>
     
  10. Akito

    Akito Thread Starter

    Joined:
    May 23, 2003
    Messages:
    931
    Well chmod worked - but it blocked me from my site as well. Also, that code didn't stop anything at all. HMMM!
     
  11. Shadow2531

    Shadow2531

    Joined:
    Apr 30, 2001
    Messages:
    2,636
    One thing you want to make sure the code does, is deny access to the midi if the referrer is null.

    If somebody puts the link on their site, I can just copy the shortcut and paste it into the address bar and there will be no referrer and I will be able to download the file. I think someone could use javascript to allow clicking on the link with no referrer either, so if the referrer is null, redirect them to your front page or the download page on your site.

    You can also disable referrer logging with opera.
     
  12. NameTooLong

    NameTooLong

    Joined:
    Dec 26, 2002
    Messages:
    325
    Yeah, but wouldn't that cause problems for Opera users just trying to use the site?
     
  13. Shadow2531

    Shadow2531

    Joined:
    Apr 30, 2001
    Messages:
    2,636
    Good point. Possibly; depending on the code. I've seen perl scripts that only allow you to download the file, if you goto the actual page and left-click. right-click and save-as won't work. And I believe it wouldn't allow the streaming of the files either. It used a form buttom that you had to click on and also used some validating code that ensured the link to the file was coming from the page.

    All the midis have a direct link to them. You should have to visit one of your pages set a cookie and have the server retrieve the file based on the session and make sure the session expires after a certain amount of time.

    Just busting out some ideas.

    I really don't see why people would link to them from their sites, when they could just download them all, zip them up and put them on their site in a matter of minutes. Either way it would be stealing and not giving you Credit for visits/downloads, but I myself wouldn't bother linking to the files, I would just get them all and offer them myself.

    The direct links to the files, I think are the problem.

    This is kind of what I am talking about
    http://www.sitepoint.com/avantgo/article.php?aid=1156

    Used with a form of course.
    You would have to prevent people from passing the id string directly in an url.

    I suppose you could also have it so that whenever somebody downloads one of the midis directly, the download actiion popups the web page that you need people to go to.

    Just some ideas.
     
  14. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/148290

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice