Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2011
    Location
    Italy
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Prevent direct file download

    Hi all,
    I have some problems with a PHP site that includes some FLV files in a video player.

    I'd like to avoid people downloading the videos by typing the url by hand (ex. http://mysite.com/video/vidTitle.flv), but at the same time, I need the same url to be accessed by the video player on my PHP page.
    This video player uses an anchor tag: <a href="/video/vidTitle.flv">...</a>

    How can I avoid the direct download from the address bar?
    Thanks

  • #2
    New Coder
    Join Date
    Jul 2011
    Posts
    67
    Thanks
    0
    Thanked 13 Times in 13 Posts
    I believe a request for an asset appearing on a page has a HTTP_REFERER flag of your site, so one option would be to check against that and send a forbidden response if it's not your site.

    Code:
    RewriteCond %{HTTP_REFERER} !www.yourdomain.com
    RewriteRule \.flv$ - [F]
    This should also stop other sites from hotlinking your assets and using up your bandwidth. It's not a perfectly solution, as there are still ways for somebody to download the file, but it should suffice for most cases.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •