Deny leechers from accessing your files

Discussion in 'Apache' started by Orangu, Aug 3, 2011.

  1. #1
    If you have files you want to protect on your site so nobody links directly to them and steals your bandwith, you can use the folowing snippet:

    <FilesMatch "\.(gif|jpe?g)$">
        SetEnvIf Referer "^http://([^/]*\.)?YOURDOMAIN.COM/" request_ok = 1
        Order Allow, Deny
        Allow from env=request_ok
    </FilesMatch>
    
    Code (markup):
    This sample would prevent anyone from accessing .gif and .jpg files except for YOURDOMAIN.COM.
    You can place this snippet in Apache config file, a virtual host, or even an .htaccess file.
     
    Orangu, Aug 3, 2011 IP