Ask Dave Taylor
  • Facebook
  • Instagram
  • Linkedin
  • Pinterest
  • Twitter
  • YouTube
  • Home
  • YouTube Videos
  • Top Categories
  • Subscribe via Email
  • Ask A Question
  • Meet Dave
  • Home
  • HTML & Web Page Design
  • Can you prevent people from linking to the media on your Web site?

Can you prevent people from linking to the media on your Web site?

February 23, 2004 / Dave Taylor / HTML & Web Page Design, Linux Shell Script Programming / 3 Comments

A friend writes:

I’m finding that some number of people are hosting my Janet Jackson
“movie” by simply linking it in from their sites, meaning *I* get to
pay for the bandwidth. Is there some way to prevent this?

Here’s what I’d do:

  1. Change your pages to refer to something called, say,

        jjackson-movie.cgi

  2. then have a script called that that essentially does this:


      echo "Content-type: image/swf";
      if [ $HTTP_REFERER != $yourdomain ] then
        stream bogus-film-for-other-folk
      else
        stream real-janet-jackson-movie
      endif

Well, it’s slightly more complicated than that, but not by much. My only concern would be that some % of browsers don’t send referrer information so for them, even if they viewed it on your page, it’d break.

Another strategy would be to have the page that includes the movie dynamically generated to include a timestamp, then this script checks to see if the timestamp is less than, say, two hours old. That’d involve two scripts instead of one, though: one for the page that contained the link, and one for the actual delivery of the movie itself.

Let’s Stay In Touch!

Never miss a single article, review or tutorial here on AskDaveTaylor, sign up for my fun weekly newsletter!
Name: 
Your email address:*
Please enter all required fields
Correct invalid entries
No spam, ever. Promise. Powered by FeedBlitz
Please choose a color:
Starbucks coffee cup I do have a lot to say, and questions of my own for that matter, but first I'd like to say thank you, Dave, for all your helpful information by buying you a cup of coffee!

3 comments on “Can you prevent people from linking to the media on your Web site?”

  1. Rob says:
    February 17, 2007 at 4:49 am

    If your server allows it, a better solution here is to use .htaccess. Being a lazy linux admin, it’s much easier to manage a centralized file than to put the code in multiple files where hotlinking needs to be prevented (the server does less work here to). Since this still relies on $HTTP_REFERER, you should keep an eye out in your access_log, then just block the baddies completely using $REMOTE_ADDR or $REMOTE_HOST
    #—–Prevent hot linking of images and other file types———-
    #requires mod_rewrite
    #The next 2 lines may also be required depending on your apache setup
    #Options +FollowSymlinks
    #RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain.com/.*$ [NC]
    RewriteRule \.(jpg|gif|js|css|swf)$ – [F]
    #-Or serve up something else to the hot linkers
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain.com/.*$ [NC]
    RewriteRule \.(jpg|gif|js|css|swf)$ busted.html [R,L]

    Reply
  2. Dave Taylor says:
    February 24, 2004 at 1:01 pm

    That’s a logical and sensible solution, Will. Hmmm…. now why didn’t I think of that?? 🙂

    Reply
  3. Will Bontrager says:
    February 24, 2004 at 9:54 am

    To ensure those without referring information, a null or empty $HTTP_REFERER could go ahead and stream the real thing. The remote page will get the file for some browsers, but will be broke for others.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

Recent Posts

  • Can I Specify my Preferred Pronouns on Pinterest?
  • What Options are there for Hiding a File or Document in Windows 11?
  • Switch from 24-Hour Time to AM/PM in Ubuntu Linux?
  • How Can I Enable Emergency Alerts in Spanish on Android?
  • Protect Your Connection and Privacy with Surfshark VPN

On Our YouTube Channel

ZAGG Invisible Shield Glass Elite Screen Protector for Google Pixel 6a -- INSTALLED!

Monoprice DT-3BT Bluetooth Desktop Speakers -- REVIEW

Categories

  • AdSense, AdWords, and PPC Help (106)
  • Amazon, eBay, and Online Shopping Help, (161)
  • Android Help (203)
  • Apple iPad Help (145)
  • Apple Watch Help (53)
  • Articles, Tutorials, and Reviews (344)
  • Auto Tech Help (12)
  • Business Advice (199)
  • Chrome OS Help (25)
  • Computer & Internet Basics (764)
  • d) None of the Above (165)
  • Facebook Help (383)
  • Google, Chrome & Gmail Help (180)
  • HTML & Web Page Design (245)
  • Instagram Help (48)
  • iPhone & iOS Help (607)
  • iPod & MP3 Player Help (173)
  • Kindle & Nook Help (93)
  • LinkedIn Help (85)
  • Linux Help (167)
  • Linux Shell Script Programming (87)
  • Mac & MacOS Help (895)
  • Most Popular (16)
  • Outlook & Office 365 Help (26)
  • PayPal Help (69)
  • Pinterest Help (54)
  • Reddit Help (18)
  • SEO & Marketing (81)
  • Spam, Scams & Security (93)
  • Trade Show News & Updates (23)
  • Twitter Help (217)
  • Video Game Tips (66)
  • Web Site Traffic Tips (62)
  • Windows PC Help (923)
  • Wordpress Help (204)
  • Writing and Publishing (72)
  • YouTube Help (46)
  • YouTube Video Reviews (159)
  • Zoom, Skype & Video Chat Help (57)

Archives

Social Connections:

Ask Dave Taylor


Follow Me on Pinterest
Follow me on Twitter
Follow me on LinkedIn
Follow me on Instagram


AskDaveTaylor on Facebook



microsoft insider mvp


This web site is for the purpose of disseminating information for educational purposes, free of charge, for the benefit of all visitors. We take great care to provide quality information. However, we do not guarantee, and accept no legal liability whatsoever arising from or connected to, the accuracy, reliability, currency or completeness of any material contained on this site or on any linked site. Further, please note that by submitting a question or comment you're agreeing to our terms of service, which are: you relinquish any subsequent rights of ownership to your material by submitting it on this site. Our lawyer says "Thanks for your cooperation."
© 2022 by Dave Taylor. "Ask Dave Taylor®" is a registered trademark of Intuitive Systems, LLC.
Privacy Policy - Terms and Conditions - Accessibility Policy